how can i convert ascii code to character in javascript
Asked
Active
Viewed 7.1k times
56
-
1JavaScript "characters" (like in many modern languages) are UTF-16 code units. If for some strange reason you have an ASCII code unit, you can easily convert it by relying on 1) ASCII code unit are the same as ASCII codepoint, 2) ASCII codepoints are the same as Unicode codepoints (for the characters in common), 3) UTF-16 encodes those characters in one UTF-16 code unit, and 4) those UTF-16 code units, although having 16 bits has the same integer value as the ASCII code units. Or, did you really just have a UTF-16 code unit are for some reason calling it ASCII? – Tom Blodget Feb 09 '17 at 17:38
2 Answers
111
String.fromCharCode(ascii_code)

Darko Kenda
- 4,781
- 1
- 28
- 31
-
1[link] (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) – Elangovan Jul 25 '14 at 10:38
-
1
15
If you want to convert Ascii Codes to Characters you can use:
String.fromCharCode(codes);
For Example:
String.fromCharCode(65,66,67);
which returns = "ABC"

Saleheen Noor
- 261
- 2
- 8