For example:
If I’ve a string which is Unicode: \u4E45
I wanna display this character to web page using JavaScript. How can I do?
And my second question is that if I’ve a Chinese character: 依
I wanna get its Unicode (\u4F9D) using JavaScript. How can I do?
Thank you very much!
If you inject a string with unicode characters via javascript into a webpage they will be displayed the way they should automatically (given that the browser innquestion support the display of that character).
This can be seen in this example: http://jsfiddle.net/KyuKE/1/
You can read the data in a textNode by accessing it’s data property which will give you a string. This string will have the
charCodeAtmethod available to get the charCode.Example can be seen here: http://jsfiddle.net/KyuKE/2/
You can read the documentation for
charCodeAthere: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/charCodeAt