Created
March 22, 2017 11:58
-
-
Save haakym/c00ed074a1d730e803e2a71ba51551f5 to your computer and use it in GitHub Desktop.
String to Hex for ZPL in JS
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 stringToHex(str) { | |
return str.split('').map(function (char) { | |
return '_' + char.charCodeAt(0).toString(16); | |
}).join(''); | |
} | |
console.log(stringToHex('ش')); // _d8_b4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original code from http://stackoverflow.com/questions/36637146/javascript-encode-string-to-hex