Home >Web Front-end >HTML Tutorial >How to return a number representing the Unicode value of a character?
# The charCodeAt() method returns a number representing the Unicode value of the character at the given index. Unicode code points range from 0 to 1,114,111. The first 128 Unicode code points directly match the ASCII character encoding.
charCodeAt(index) supports the following parameters:
You can try running the following code to return a number representing the Unicode value of a character:
<html> <head> <title>JavaScript String charCodeAt() Method</title> </head> <body> <script> var str = new String( "This is string" ); document.write("str.charCodeAt(0) is:" + str.charCodeAt(0)); document.write("<br />str.charCodeAt(1) is:" + str.charCodeAt(1)); document.write("<br />str.charCodeAt(2) is:" + str.charCodeAt(2)); document.write("<br />str.charCodeAt(3) is:" + str.charCodeAt(3)); document.write("<br />str.charCodeAt(4) is:" + str.charCodeAt(4)); document.write("<br />str.charCodeAt(5) is:" + str.charCodeAt(5)); </script> </body> </html>
The above is the detailed content of How to return a number representing the Unicode value of a character?. For more information, please follow other related articles on the PHP Chinese website!