简体   繁体   中英

weird characters in Chinese

In browser, it's showing something like below:

在此处输入图片说明

when I inspect it in developer console, it is showing normal:

在此处输入链接说明

so, it looks like the colon is a not being improperly encoded.

The problem is that I don't have control of the content, the information is retrieved from somewhere else using ajax call and I use jQuery to retrieve city information.

var toCity = $(infoOutHtml).find('#HeaderDes').text();

when I console.log(toCity) it shows normal in console: 目 的 地:中国

but when I render it to html, it become weird:

var Information = "<div id=\"trackingNum\" class=\"spacer-banner blueFontWhiteBg\">"+
     "<span  id=\"transit-id\">"+toCity +"</span>"+
"</div>"

$($info).html(information);

I am just wondering what's the problem here? how to ignore the colon before render it to html?

I tried this, but doesn't work at all:

function somefunction(string){

  return string.replace(/:/,'\\\\:');

}

toCity = somefunction(toCity);

@krtek是正确的,我使用了没有“:”的字体系列。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM