当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JavaScript fromCharCode() 方法
The fromCharCode() takes the specified Unicode values and returns a string.
fromCharCode()将Unicode码转换为对应的字符并返回为字符串
String.fromCharCode(numX,numX,...,numX) |
Parameter 参数 | Description 注释 |
---|---|
numX Unicode码 | Required. One or more Unicode values 必选项。一个或多个Unicode 值 |
Note: This method is a static method of String - it is not used as a method of a String object that you have created. The syntax is always String.fromCharCode() and not myStringObject.fromCharCode().
注意:本方法只适用于静态字符串 - 不能用于你自定义的字符串对象。
In this example we will write "HELLO" and "ABC" from Unicode:
在本例中,我们将通过Unicode码输出"HELLO"和”ABC“:
<script type="text/javascript"> document.write(String.fromCharCode(72,69,76,76,79)) </script> |
The output of the code above will be:
输出结果为:
HELLO |
fromCharCode()
How to use fromCharCode() to display a string from Unicode values.
如何用fromCharCode()把Unicode码转为对应字符并输出