I have an array containing strings with special unicode characters:
var a = [
["a", 33],
["h\u016B", 44],
["s\u00EF", 51],
...
];
When I loop over this array:
for (i=0;i<a.length;i++) {
document.write(a[i][0] + "<br />");
}
It prints characters with accents:
a
hù
sô
...
and I want:
a
h\u016B
s\u00EF
...
How can I achieve this in Javascript?
if you have a unicode char and you want it as a string you can do this
Something like this?
Result
JSFiddle
So, gotten here tried to answer this question: Javascript: display unicode as it is but it has been closed because of this question here.
Just another answer for this problem: It is also possible (at least in some modern browsers) to use the String.raw - function
Syntax is like this:
Here is a working fiddle (Chrome, FF): http://jsfiddle.net/w9L6qgt6/1/
javascript's
string.charCodeAt()
should help. I.e."test".charCodeAt(0)
will return the numeric code for"t"
.Beyond that, you'd need to write an if statement to check if the character is non-ASCII, etc.