Is it possible to convert a hexadecimal value to its respective ASCII character, not using the String.fromCharCode
method, in JavaScript?
For example:
JavaScript:
0x61 // 97
String.fromCharCode(0x61) // a
C-like:
(char)0x61 // a
There is also the Unicode equivalent of \x
:
var char = "\u0061";
You can use the \xNN
notation:
var str = "\x61";
Not in that fashion, because JavaScript is loosely typed, and does not allow one to define a variable's data type.
What you can do, though, is creating a shortcut:
var char = String.fromCharCode; // copy the function into another variable
Then you can call char
instead of String.fromCharCode
:
char(0x61); // a
Which is quite close to what you want (and perhaps more readable/requiring less typing).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With