In JavaScript, how to get a string representation of an ASCII value, e.g. how to turn 65 into A?
-
2you may mark his answer as correct. There's a little check right below the downvote arrow.kongaraju– kongaraju2012-09-27 10:04:51 +00:00Commented Sep 27, 2012 at 10:04
-
See also: [How to convert from Hex to ASCII in javascript?][1] [1]: stackoverflow.com/questions/3745666/…BearCode– BearCode2013-06-12 04:07:51 +00:00Commented Jun 12, 2013 at 4:07
Add a comment
|
4 Answers
The fromCharCode method converts ASCII to a string:
<script type="text/javascript">
document.write(String.fromCharCode(65,66,67)); // ABC
</script>
1 Comment
Michał Perłakowski
See also MDN docs.
A reference for those of us that don't like w3schools ;)
Usage:
var myAString = String.fromCharCode(65)
Comments
The method you're looking for is String.fromCharCode (http://www.w3schools.com/jsref/jsref_fromCharCode.asp).