Javascript Character (ascii) To Hex
Hey all i am in need of something simple to convert character(s) into ASCII and then make that into a Hex code. So as an example the 'A' character would be: 0xF100 + ascii_code = H
Solution 1:
Number's toString
accepts a radix parameter, with which you can convert the ASCII code to hexadecimal like this:
vardata = "A";
console.log("0xF1" + data.charCodeAt(0).toString(16));
16 means base 16, which is hexadecimal.
Post a Comment for "Javascript Character (ascii) To Hex"