码迷,mamicode.com
首页 > Web开发 > 详细

【JS】CharToAsciiToBinaryToAsciiToChar

时间:2017-04-01 01:00:35      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:head   query   src   back   chart   append   script   from   div   

<!DOCTYPE html>
<html>
<head>
<script src="/jquery/jquery-1.11.1.min.js"></script>

<script>
var str="cww"
for(var i=0;i<3;i++){

document.write("Origin:"+str[i]);
$("body").append("<br>")
t1=str.charCodeAt(i);
document.write("ASCII:"+t1);
t2=t1.toString(2);
$("body").append("<br>")
document.write("Binary:"+t2);
$("body").append("<br>")
t3=parseInt(t2,2);
document.write("BackToAsc:\t"+t3);
$("body").append("<br>")
t4=String.fromCharCode(t3);
document.write("Binary:"+t4);
$("body").append("<br>")
$("body").append("<br>")

}
</script>

</head>
<body>

</body>
</html>

 

结果:

Origin:c
ASCII:99
Binary:1100011
BackToAsc:99
Binary:c

Origin:w
ASCII:119
Binary:1110111
BackToAsc:119
Binary:w

Origin:w
ASCII:119
Binary:1110111
BackToAsc:119
Binary:w

 

【JS】CharToAsciiToBinaryToAsciiToChar

标签:head   query   src   back   chart   append   script   from   div   

原文地址:http://www.cnblogs.com/liez/p/6654135.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!