谁能给我讲讲这是什么意思? 不急,在线等,明白后立即结贴!
1: OldRot13(s);这个函数是做什么的,
2: fromCharCode从一些 Unicode 字符值中返回一个字符串。这是什么意思,Unicode 字符值又是什么东西?
程式段:
<script>
var s = "A SECRET MESSAGE! ";
// Encode it:
var sEncoded = OldRot13(s);
window.alert(sEncoded);
// Decode it:
s = OldRot13(sEncoded);
window.alert(s);
function OldRot13(s)
{
var sResult = "";
var i = 0;
var d = 0;
// Check every character in the string
for (i = 0; i < s.length; i++)
{
// Get the next character
d = s.charCodeAt(i);
// Is it an upper-case character?
if ((d >= 65) && (d <= 90))
{
// Increment it
d += 13;
// Rotate any over-flows
if (d > 90)
{
d = 64 + (d - 90);
}
}
// Add the character to the string
sResult += String.fromCharCode(d);
}
// Return the result
return sResult;
}
</script>