使用javascript将二进制文件转换为文本 [英] Converting Binary to text using javascript

查看:90
本文介绍了使用javascript将二进制文件转换为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将二进制代码转换为使用javascript的文本?我已经将文本转换为二进制文件,但有没有办法以相反的方式进行操作?这是我的代码:

 <!doctype html> 
< html>
< head>
< title> Binary Converter< / title>
< script type =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js>< / script>
< script type =text / javascript>
函数convertBinary(){
var output = document.getElementById(outputBinary);
var input = document.getElementById(inputBinary).value;
output.value =;
for(i = 0; i< input.length; i ++){var e = input [i] .charCodeAt(0); var s =;
do {
var a = e%2;
e =(e-a)/ 2;
s = a + s;
} while(e!= 0); (s.length< 8){s =0+ s;}
output.value + = s;
}
}
< / script>
< / head>
< body>
< center>
< div class =container>
< span class =main>二进制转换器< / span>< br>