Last active
August 29, 2015 14:12
-
-
Save NinoFocus/3d3c1301390934f894ee to your computer and use it in GitHub Desktop.
to_css_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
// 文字转为CSS友好的Unicode | |
// 在JavaScript的控制台中执行 | |
// | |
// to_css_unicode('启用') ==> '\542F\7528' | |
function to_css_unicode(text) { | |
return escape(text).replace(/\%u/g, '\\'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment