Created
June 18, 2014 15:32
-
-
Save bloodyowl/c3c5876574b6698d0f36 to your computer and use it in GitHub Desktop.
toUnicode
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 toUnicode(string) { | |
var index = -1 | |
var length = string.length | |
var chars = [] | |
var item | |
while(++index < length) { | |
item = string.charCodeAt(index).toString(16).toUpperCase() | |
item = "\\u" + Array(5 - item.length).join("0") + item | |
chars.push(item) | |
} | |
return chars | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment