js 字符与ASCII码互转

 

将字符转为ASCII码

var str = "A";
str.charCodeAt();  // 65

var str1 = 'a';
str1.charCodeAt();  // 97

 

将ASCII码转为字符

var num = 97;
String.fromCharCode(num);  // 'a'

var num1 = 100;
String.fromCharCode(num1);  // 'd'

 

参考文章: http://blog.csdn.net/xiaobing_hope/article/details/78645273

fromCharCode
posted @ 2018-02-24 13:05  草木物语  阅读(16589)  评论(2编辑  收藏  举报