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

JavaScript
JS数学对象参考
JS字符串对象参考
JS函数参考
JS事件参考
Javascript 常用正则表达式
FF和IE下的js兼容性问题
jQuery 简单介绍
jQuery / 核心 / $(expression, [context] ) 函数
jQuery / 核心 / $(html) 函数
如何使用JS来判断浏览器类型(ie、firefox,等等)
Javascript在IE和FireFox中的不同表现
3个js字符编码函数区别
javascript 中的 XMLDOM 对象

JavaScript fromCharCode() 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 427 ::
收藏到网摘: 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

登陆 | 还没注册?