数码资讯
在js中把一个字符转换成ASCII值的函数示例代码
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
字符转换ASCII码:用charcodeat();
ASCII码字符:将使用fromcharcode();
看一个小例子
复制代码代码如下所示:
;
代码= str.charcodeat();
str2 = string.fromcharcode(代码);
STR3 = string.fromcharcode(0x60 + 26);
document.write(代码+);
document.write(str2 +);
document.write(STR3);
输出:
六十五
一
Z
ASCII码字符:将使用fromcharcode();
看一个小例子
复制代码代码如下所示:
;
代码= str.charcodeat();
str2 = string.fromcharcode(代码);
STR3 = string.fromcharcode(0x60 + 26);
document.write(代码+);
document.write(str2 +);
document.write(STR3);
输出:
六十五
一
Z
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。