Created
August 21, 2015 10:55
-
-
Save JavaScript-Packer/2a4997ce64624106926b to your computer and use it in GitHub Desktop.
Unicode and hexdecimal encoding so that less characters used when character code range is less than 256
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 unicodeEscape(d) { | |
| for (var b = "", e = 0, a, c; !isNaN(a = d.charCodeAt(e++)); ) c = a.toString(16), | |
| b += 256 > a ? "\\x" + (15 < a ? "" :"0") + c :"\\u" + ("0000" + c).slice(-4); | |
| return b; | |
| } | |
| alert(unicodeEscape("test")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment