Created
November 2, 2012 10:46
-
-
Save tomvdv/4000109 to your computer and use it in GitHub Desktop.
Convert characters for comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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