Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reverse String.fromCharCode?

String.fromCharCode(72) gives H. How to get number 72 from char H?

like image 391
IAdapter Avatar asked Jan 15 '10 13:01

IAdapter


People also ask

What is string fromCharCode ()?

The String. fromCharCode() method converts Unicode values to characters. The String. fromCharCode() is a static method of the String object. The syntax is always String.

How does fromCharCode work?

The fromCharCode() method accepts a sequence of Unicode values. These Unicode values are UTF-16 values (16-bit integers between 0 and 65535) that are converted to characters and concatenated together in a string. This resulting string is then returned by the fromCharCode() method.

What is the use of charCodeAt ()?

The charCodeAt() method returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index.

How do you use Charcodes?

Definition and Usage Note: The charCode property is deprecated. Use the key property instead. The charCode property returns the Unicode character code of the key that triggered the onkeypress event. The Unicode character code is the number of a character (e.g. the number "97" represents the letter "a").


2 Answers

'H'.charCodeAt(0) 
like image 179
Silvio Donnini Avatar answered Sep 23 '22 17:09

Silvio Donnini


Use charCodeAt:

var str = 'H'; var charcode = str.charCodeAt(0); 
like image 21
Tatu Ulmanen Avatar answered Sep 25 '22 17:09

Tatu Ulmanen