Expand my Community achievements bar.

SOLVED

Ascii Codes

Avatar

Level 2

Is there a function that can convert an ascii code to the proper character?

ie: in excel, one can use code() and char() to go back and forth.

Found some ref to \u0041 = A, but not sure if this is the right method?

Any assistance greatly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

CODE("A") could be written in JavaScript as "A".charCodeAt(0), where the argument to charCodeAt is the position in the string so "AB".charCodeAt(1) would give you the code of B

and

CHAR(65) could be written in JavaScript as String.fromCharCode(65).  The method fromCharCode can take a list so String.fromCharCode(65,66,67) will return "ABC".

Bruce

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

CODE("A") could be written in JavaScript as "A".charCodeAt(0), where the argument to charCodeAt is the position in the string so "AB".charCodeAt(1) would give you the code of B

and

CHAR(65) could be written in JavaScript as String.fromCharCode(65).  The method fromCharCode can take a list so String.fromCharCode(65,66,67) will return "ABC".

Bruce

Avatar

Level 2

Thanks - this solved my issue.