My JavaScript get string value from server:
(我的JavaScript从服务器获取字符串值:)
var name = VALUE_FROM_SERVER;
This name
will be shown on a web page, since name
contains Scandinavian letter (for example, name could be T?yoe?v? ) I need to encode it somehow to display it correctly on the browser.
(该name
将显示在网页上,因为name
包含斯堪的纳维亚字母(例如,名称可能是T?yoe?v? ),因此我需要对其进行编码以使其在浏览器中正确显示。)
In JavaScript, what is the most efficient way to encode all those Scandinavian letters?
(在JavaScript中,对所有这些斯堪的纳维亚字母进行编码的最有效方法是什么?)
( I prefer to do it with Javascript. )
(( 我更喜欢使用JavaScript。 ))
(eg I would like to create a JS function which takes T?yoe?v? as parameter and returns T?yoe?v?)
((例如,我想创建一个将T?yoe?v?作为参数并返回T?yoe?v?的JS函数))
var encoder=function(string){
for(var s=0; s<string.length; s++){
//Check each letter in the string, if it is Scandinavian, encode it??
}
}
ask by Leem translate from so