In JavaScript, how to get a string representation of an ASCII value, e.g. how to turn 65
into A
?
Asked
Active
Viewed 9.7k times
69

Michał Perłakowski
- 88,409
- 26
- 156
- 177

Sakthivel
- 1,883
- 12
- 29
- 41
-
2you may mark his answer as correct. There's a little check right below the downvote arrow. – kongaraju Sep 27 '12 at 10:04
-
See also: [How to convert from Hex to ASCII in javascript?][1] [1]: http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript – BearCode Jun 12 '13 at 04:07
4 Answers
122
The fromCharCode method converts ASCII to a string:
<script type="text/javascript">
document.write(String.fromCharCode(65,66,67)); // ABC
</script>
-
See also [MDN docs](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode). – Michał Perłakowski Jan 02 '16 at 18:56
10
A reference for those of us that don't like w3schools ;)
Usage:
var myAString = String.fromCharCode(65)

UpTheCreek
- 31,444
- 34
- 152
- 221
3
The method you're looking for is String.fromCharCode (http://www.w3schools.com/jsref/jsref_fromCharCode.asp).

jonnii
- 28,019
- 8
- 80
- 108
-1