Skip to content

Instantly share code, notes, and snippets.

@rluvaton
Created January 8, 2019 13:39
Show Gist options
  • Save rluvaton/b43f7f709e64335990a9fedb14c425d1 to your computer and use it in GitHub Desktop.
Save rluvaton/b43f7f709e64335990a9fedb14c425d1 to your computer and use it in GitHub Desktop.
Unicode to text converter
function unicodeToText(b, endian, backSlashU) {
var d, c = "";
if (!backSlashU) {
c = "\\\\u"
}
return b.replace(new RegExp(c + "([0-9a-fA-F]{4})", "g"), function(e, f) {
d = parseInt(f, 16);
if (endian) {
d = (((d & 255) << 8) | ((d & 65280) >>> 8))
}
return String.fromCharCode(d)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment