Skip to content

Instantly share code, notes, and snippets.

@lokeb
Created August 23, 2018 19:31
Show Gist options
  • Save lokeb/f4818fb57380566d57991374459805c7 to your computer and use it in GitHub Desktop.
Save lokeb/f4818fb57380566d57991374459805c7 to your computer and use it in GitHub Desktop.
Prototype methods to convert Currency.csv Unicode values
String.prototype.hexDecode = function () {
var j;
var hexes = this.split("\\u").slice(1);
var back = "";
for (j = 0; j < hexes.length; j++) {
back += String.fromCharCode(parseInt(hexes[j], 16));
}
return back;
}
String.prototype.hexEncode = function () {
var hex, i;
var result = "";
for (i = 0; i < this.length; i++) {
hex = this.charCodeAt(i).toString(16);
result += "\\u" + ("000" + hex).slice(-4);
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment