Skip to content

Instantly share code, notes, and snippets.

@bloodyowl
Created June 18, 2014 15:32
Show Gist options
  • Save bloodyowl/c3c5876574b6698d0f36 to your computer and use it in GitHub Desktop.
Save bloodyowl/c3c5876574b6698d0f36 to your computer and use it in GitHub Desktop.
toUnicode
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