Skip to content

Instantly share code, notes, and snippets.

@eikes
Created February 22, 2012 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eikes/1886209 to your computer and use it in GitHub Desktop.
Save eikes/1886209 to your computer and use it in GitHub Desktop.
String.prototype.toUnicode = function (){
function pad(t) {
return t.length == 4 ? t : pad("0" + t);
}
var r="";
for (var i = 0; i < this.length; i++) {
r += "\\u" + pad(this.charCodeAt(i).toString(16));
}
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment