JSFiddle - React, Tailwind, and code Playground
by cancerbero_sgx
JavaScript
function toUnicode(theString) {
var unicodeString = '';
for ( var i = 0; i < theString.length; i++) {
var code = theString.charCodeAt(i);
document.write(code+", ");
if (code > 99) {
var theUnicode = theString.charCodeAt(i).toString(16).toUpperCase();
while (theUnicode.length < 4) {
theUnicode = '0' + theUnicode;
}
theUnicode = '\\u' + theUnicode;
unicodeString += theUnicode;
} else {
unicodeString += String.fromCharCode(code); ;
}
}
return unicodeString;
}
document.write(toUnicode("{\"alskdj\": 'hello 日本語'}"))