将代码文本解码为ASCII失败

时间:2017-09-14 04:52:56

标签: javascript html

我的程序将普通文本编码为ASCII。一切都很好,除了解码不起作用。有什么问题?

此外,我不希望在打印编码文本时出现逗号。哦,我也希望包括Caesar密码。

Dim SerCount As Long

SerCount = sh.Chart.SeriesCollection.Count

Select Case SerCount
    Case 1

    Case 2

    ' etc...

End Select
function code() {
  var leer = document.getElementById('1').value,
      array = [];
  for (var i = 0; i < leer.length; i++) {
    array[i] = leer[i].charCodeAt(0);
  }
  document.getElementById('2').innerHTML = 'Chale, chale ' + array;
}

function decode() {
  var leer = document.getElementById('1').value,
      array = [];
  for (var i = 0, char; char = leer[i]; i++) {
    array[i] = String.fromCharCode(leer[i].charCodeAt(0));
  }
  document.getElementById('2').innerHTML = 'Chale, chale ' + array;
}

3 个答案:

答案 0 :(得分:0)

你应该在解码函数中使用字符串字符串而不是数组

function decode() {
var leer = document.getElementById('1').value,
str = "";
for (var i = 0, char; char = leer[i]; i++) {
    str += String.fromCharCode(leer[i].charCodeAt(0));
}
document.getElementById('2').innerHTML = 'Chale, chale ' + str;}

答案 1 :(得分:0)

你可以使用arrayname.join(''); 这是工作片段。

function code() {
  var leer = document.getElementById('1').value,
      array = [];
	  //debugger;
  for (var i = 0; i < leer.length; i++) {
    array[i] = leer[i].charCodeAt(0);
  }
  document.getElementById('2').innerHTML = 'Chale, chale ' + array.join(' ');
}

function decode() {
  var leer = document.getElementById('1').value,
      array = [];
	//debugger;
  for (var i = 0, char; char = leer[i]; i++) {
    array[i] = String.fromCharCode(leer[i].charCodeAt(0));
  }
  document.getElementById('2').innerHTML = 'Chale, chale ' + array.join(' ');
}
<html>

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="exCSS.css">
</head>

<body>
<form>
  Escriba el Mensaje:<br><br>
  <textarea id="1" rows="10" cols="40"></textarea>
  <br><br>
  <br><br> Elige una opción:
  <br><br>
  <input type="button" name="cifra" value="Cifrar" onclick="code()">
  <input type="button" name="decifra" value="Decifrar" onclick="decode()">
  <br><br>
  <textarea id="2" rows="5" cols="40"></textarea>
</form>
</body>
</html>

希望,这对你有所帮助。谢谢:))

答案 2 :(得分:0)

&#13;
&#13;
foreach ($file_path as $path){
$array_1[] = array(
    'driver'        => 'LocalFileSystem',           // driver for accessing file system (REQUIRED)
    'path'          => $path,                 // path to files (REQUIRED)
    'URL'           => $path, // URL to files (REQUIRED)
    'trashHash'     => 't1_Lw',                     // elFinder's hash of trash folder
    'winHashFix'    => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
    'uploadDeny'    => array('all', '*'),                // All Mimetypes not allowed to upload
    'uploadOrder'   => array('deny', 'allow'),      // allowed Mimetype `image` and `text/plain` only
    'accessControl' => 'access'                     // disable and hide dot starting files (OPTIONAL)
);
&#13;
    array(0 =>
 array(
        'driver'        => 'LocalFileSystem',    
        'path'          => 'path/to/files/first_root', 
        'URL'           => 'http://localhost/files/first_root/', 
        'alias'         => 'First home',
        'accessControl' => 'access'
    ), 
1 =>
    array(
        'driver'        => 'LocalFileSystem',
        'path'          => 'path/to/files/second_root',
        'URL'           => 'http://localhost/files/second_root/',
        'alias'         => 'Second home'
    ));
&#13;
&#13;
&#13;

相关问题