Skip to content

Instantly share code, notes, and snippets.

@lushijie
Created December 26, 2017 08:05
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 lushijie/9c384a6abf764f20e2fabb3c9b404f74 to your computer and use it in GitHub Desktop.
Save lushijie/9c384a6abf764f20e2fabb3c9b404f74 to your computer and use it in GitHub Desktop.
转化为unicode
function toUnicodeSequence(str) {
for(var i = str.length; i--;) {
str = str.slice(0, i) + '\\u'
+ ('000' + str.charCodeAt(i).toString(16)).slice(-4)
+ str.slice(i + 1);
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment