Posted in Javascript onNovember 21, 2013
字符转ascii码:用charCodeAt();
ascii码转字符:用fromCharCode();
看一个小例子
<script> str="A"; code = str.charCodeAt(); str2 = String.fromCharCode(code); str3 = String.fromCharCode(0x60+26); document.write(code+'<br />'); document.write(str2+'<br />'); document.write(str3); </script>
输出:
65
A
z
JS中把字符转成ASCII值的函数示例代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@