方法列举:
字符转ASCII码:用charCodeAt();
ASCII码转字符:用fromCharCode();
代码示例:
<script type="text/javascript">
var username="ABC012";
for(var i=username.length-1;i>=0;i--){
var str = username.charAt(i);
var code = str.charCodeAt();
usernameMi+=code;
}
document.write(str+'<br />');
document.write(usernameMi+'<br />');
</script>
输出结果:
ABC012
504948676665