Skip to content

Instantly share code, notes, and snippets.

@tomvdv
Created November 2, 2012 10:46
Show Gist options
  • Save tomvdv/4000109 to your computer and use it in GitHub Desktop.
Save tomvdv/4000109 to your computer and use it in GitHub Desktop.
Convert characters for comparison
function string_as_unicode_escape(input) {
var output = '';
for (var i = 0, l = input.length; i < l; i++)
output += '\\u' + (input.charCodeAt(i) + 0x10000).toString(16).slice(1);
return output;
}
document.write(string_as_unicode_escape('abcd'));​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment