stringObj.charCodeAt(index)
- stringObj 必选项。一个 String 对象或文字。
- index 必选项。指定字符基于零的索引。
返回指定字符的 Unicode 编码,等同于 VBScript 的 AscW 函数。
var str = "ITPOW";
alert(str.charCodeAt(2)); // 显示“网”的 Unicode 编码。
String.fromCharCode(code1, code2, ..., coden)
- code 参数是要转换为字符串的 Unicode 字符值序列。
从一些 Unicode 字符值中回一个字符串。
alert(String.fromCharCode(21315, 19968, 32593, 32476)); //显示“ITPOW”。
顺便说一下,还有一个函数是 charAt(index),用于获取字符串中 index 位置(从 0 开始)的字符。