当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JavaScript fromCharCode() 方法

JavaScript
JS 介绍
JS 怎样使用
JS 在哪使用
JS 变量
JS If...Else
JS Switch
JS 操作符
JS Popup Boxes
JS 函数
JS For 循环
JS While 循环
JS Break 循环
JS For...In
JS 事件
JS Try...Catch
JS Throw
JS onerror
JS 特殊字符
JS Guidelines
JS 对象介绍

JavaScript fromCharCode() 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 425 ::
收藏到网摘: n/a

Definition and Usage
定义与用法

The fromCharCode() takes the specified Unicode values and returns a string.
fromCharCode()将Unicode码转换为对应的字符并返回为字符串

Syntax
语法

String.fromCharCode(numX,numX,...,numX)

Parameter
参数
Description
注释
numX
Unicode码
Required. One or more Unicode values
必选项。一个或多个Unicode 值


Tips and Notes
注意

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().
注意:本方法只适用于静态字符串 - 不能用于你自定义的字符串对象。


Example
实例

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))
document.write("<br />")
document.write(String.fromCharCode(65,66,67))
</script>

The output of the code above will be:
输出结果为:

HELLO
ABC


Try-It-Yourself Demos
互动演练

fromCharCode()
How to use fromCharCode() to display a string from Unicode values.
如何用fromCharCode()把Unicode码转为对应字符并输出

评论 (0) All

登陆 | 还没注册?