Created
December 26, 2017 08:05
-
-
Save lushijie/9c384a6abf764f20e2fabb3c9b404f74 to your computer and use it in GitHub Desktop.
转化为unicode
This file contains 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 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