怎么把A-Z变成ASIIC码的数字
如何把A-Z变成ASIIC码的数字?
写了个类似密码转换的程序,ASIIC码可以转换成字母,但是字母没法转换成ASIIC码的数字,求大神赐教:
------解决方案--------------------
str.charCodeAt(i)
------解决方案--------------------
写了个类似密码转换的程序,ASIIC码可以转换成字母,但是字母没法转换成ASIIC码的数字,求大神赐教:
<!DOCTYPE html>
<html>
<head>
<script>
function convert(degree)
{
if (degree=="C")
{
F=String.fromCharCode(document.getElementById("o").value);
document.getElementById("t").value=F;
}
else
{
C=parseInt(document.getElementById("t").value,16);
document.getElementById("o").value=C;
}
}
</script>
</head>
<body>
<p></p><b>Insert a number into one of the input fields below:</b></p>
<form>
<input id="o" name="c" onkeyup="convert('C')"> original code<br>
equals<br>
<input id="t" name="f" onkeyup="convert('F')"> target code
</form>
</body>
</html>
------解决方案--------------------
str.charCodeAt(i)
------解决方案--------------------
s = document.getElementById("t").value;
C = '';
for(i=0; i<s.length; i++) C += s.charCodeAt(i).toString(16);
document.getElementById("o").value = C;