Javascript character (ASCII) to Hex

前端 未结 1 1584
南旧
南旧 2020-12-15 19:04

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:

<
相关标签:
1条回答
  • 2020-12-15 19:50

    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));
    

    16 means base 16, which is hexadecimal.

    0 讨论(0)
提交回复
热议问题