Javascript字符(ASCII)到十六进制 [英] Javascript character (ASCII) to Hex
本文介绍了Javascript字符(ASCII)到十六进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我需要一些简单的东西将字符转换为ASCII,然后将其转换为十六进制代码。
Hey all i am in need of something simple to convert character(s) into ASCII and then make that into a Hex code.
A字符为:
0xF100 + ascii_code = Hex
,结果是:
0xF100 + 65 = 0xF141
65将是上面的字符A。我一直在寻找一些javascript,将我的字符,并从它做一个十六进制...但我没有真正找到任何东西,这将做这.... ....
65 would be the character "A" above. I've been looking for some javascript that would take my character and make a Hex from it... But i haven't really found anything that would do this....
任何帮助都很棒!
推荐答案
Number's toString
接受radix参数,可以转换ASCII代码到这样的十六进制。
Number's toString
accepts a radix parameter, with which you can convert the ASCII code to hexadecimal like this.
var data = "A";
console.log("0xF1" + data.charCodeAt(0).toString(16));
这篇关于Javascript字符(ASCII)到十六进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文