Convert this unicode to string with javascript (Thai Language) -


มอเตอร์ไซค์ 

can convert unicode string js. (it thailand language)

i use

console.log(string.fromcharcode("มอเตอร์ไซค์")); 

and it's not correct. if right show มอเตอร์ไซค์

your unicode string encoded using html entity notation. means whatever encoded string expected end in middle of html document, seen html parser.

if you've somehow got string in javascript in browser, can encoded unicode letting browser parse it:

var str = "มอเตอร์ไซค์";  var elem = document.createelement("div");  elem.innerhtml = str;  alert(elem.textcontent);

the string.fromcharcode() function expects 1 or more numeric arguments; won't understand html entities. if you're not in browser (like, if you've got string in node.js program or that), convert string own code:

var str = "มอเตอร์ไซค์"; var thai = string.fromcharcode.apply(string, str.match(/x[^;]*;/g).map(function(n) { return parseint(n.slice(1, -1), 16); })); 

that conversion work when code points involved within first 64k values.


Comments