How to create a string or char from an ASCII value in JavaScript?
Asked Answered
P

4

70

In JavaScript, how to get a string representation of an ASCII value, e.g. how to turn 65 into A?

Pestiferous answered 2/3, 2009 at 11:41 Comment(2)
you may mark his answer as correct. There's a little check right below the downvote arrow.Eveleen
See also: [How to convert from Hex to ASCII in javascript?][1] [1]: #3746166Asset
F
123

The fromCharCode method converts ASCII to a string:

<script type="text/javascript">
document.write(String.fromCharCode(65,66,67)); // ABC
</script>
Fluorocarbon answered 2/3, 2009 at 11:44 Comment(1)
See also MDN docs.Strongroom
P
10

A reference for those of us that don't like w3schools ;)

Usage:

var myAString = String.fromCharCode(65)

Pisa answered 16/9, 2014 at 12:28 Comment(0)
C
4

The method you're looking for is String.fromCharCode (http://www.w3schools.com/jsref/jsref_fromCharCode.asp).

Cherrylchersonese answered 2/3, 2009 at 11:45 Comment(0)
G
0

charCodeAt() method can be used to get the ASCII value.

Gestate answered 11/4, 2023 at 7:14 Comment(2)
The question asks the other way.Walford
however the question asks the other way, it's good to also have this referenced, but a little explanation may fit.Euniceeunuch

© 2022 - 2024 — McMap. All rights reserved.