Skip to content Skip to sidebar Skip to footer

Javascript Convert String Representation Of Hex Value To Hex

In Javascript, how do I convert a string representation of a hex value into it's hex representation ? What I have returning from a checksum routine is a string value 'FE'. What I

Solution 1:

like this

var hex = parseInt("FF", 16);

Solution 2:

For the string \xFE, escape the backslash: var hex = '\\x'+'FE'

To convert 'FE' to a Number use +('0xFE')

To show +('0xFE') as a hexadecimal, use (224).toString(16), or '0x'+((254).toString(16))


Post a Comment for "Javascript Convert String Representation Of Hex Value To Hex"