我正在寻找一种方法将我的"二进制文件的输入字符拆分为文本" n = 8个字符后的翻译器。我假设这是如何使输入与我的二进制字典对应。 例如: 如果我输入" 011000010110001001100011"在输入字段中,输出将给我" abc" (01100001 = a,01100010 = b,01100011 = c)。
然而,当我翻译单个二进制代码时似乎工作正常。 例如: 我能翻译" 01100001"到" a"。
在将我已经完成的"文本修改为二进制文件"之后,到目前为止,这是我所拥有的。译者:
<div><center>
<head><title>Binary to text</title></head>
<h3><u>Write letters here:</u><br/></h3>
<input id='inp' />
<button style="background: white; border: 2px solid #000; font-family: Verdana;" id='butt'>Translate</button>
<br><br>Resultat: <input size="34" type="text" id="out" name="binary" readonly/>
<br>
<br><br><form action="http://localhost/translator/morse-alfabet.php"><input style="width: 400px; background: white; height: 40px; border: 2px solid #000; font-family: Verdana; font-weight:bold;" type="submit" value="Binary to text" /></form></center></div></center></div>
<body background="http://www.pixelstalk.net/wp-content/uploads/2016/10/Free-HD-blurred-wallpaper.jpg">
<script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-58d22c749295bca52f487966e382a94a495ac103faca9206cbd160bdf8aedf2a.js'></script>
<script>var binary = {
'01100001': 'a',
'01100010': 'b',
'01100011': 'c',
'01100100': 'd',
'01100101': 'e',
'01100110': 'f',
'01100111': 'g',
'01101000': 'h',
'01101001': 'i',
'01101010': 'j',
'01101011': 'k',
'01101100': 'l',
'01101101': 'm',
'01101110': 'n',
'01101111': 'o',
'01110000': 'p',
'01110001': 'q',
'01110010': 'r',
'01110011': 's',
'01110100': 't',
'01110101': 'u',
'01110110': 'v',
'01110111': 'w',
'01111000': 'x',
'01111001': 'y',
'01111010': 'z',
'00110001': '1',
'00110010': '2',
'00110011': '3',
'00110100': '4',
'00110101': '5',
'00110110': '6',
'00110111': '7',
'00111000': '8',
'00111001': '9',
'00110000': '0',
'00100000': ' ',
'00111111': '?',
'00111010': ':',
'00101000': '(',
'00101001': ')',
'00101110': '.',
'00101100': ',',
'00111011': ';'
};
var inp = document.getElementById('inp');
var butt = document.getElementById('butt');
var out = document.getElementById('out');
butt.addEventListener('click', function () {
var conv = inp.value;
conv = conv.split(' ');
for (var i = 0; i < conv.length; i++) {
if (window.CP.shouldStopExecution(1)) {
break;
}
conv[i] = binary[conv[i]];
}
window.CP.exitedLoop(1);
conv = conv.join('');
console.log(conv);
out.value = conv;
});
</script>
<style>
div {
height: 150px;
width: 400px;
background: white;
position: fixed;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -200px;
}
div {
font-family: Verdana;
color: black;
border: 2px solid #000;
}
</style>
</body></html>
&#13;