35 lines
820 B
Text
35 lines
820 B
Text
/*
|
|
ROT-13 in Neko
|
|
*/
|
|
|
|
/* Assume ASCII encoding */
|
|
var rotate13 = function(c) {
|
|
if (c >= 65 && c <= 77) || (c >= 97 && c <= 109)
|
|
c += 13
|
|
else
|
|
if (c >= 78 && c <= 90) || (c >= 110 && c <= 122)
|
|
c -= 13
|
|
return c
|
|
}
|
|
|
|
var rot13 = function(s) {
|
|
var r = $scopy(s)
|
|
var len = $ssize(r)
|
|
var pos = 0
|
|
while pos < len {
|
|
$sset(r, pos, rotate13($sget(r, pos)))
|
|
pos += 1
|
|
}
|
|
return r
|
|
}
|
|
|
|
var msg = $loader.args[0]
|
|
if msg == null {
|
|
var testing = "[abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ]"
|
|
$print(testing, "\n", replaced = rot13(testing), "\n")
|
|
$print(rot13(replaced), "\n")
|
|
$print("\n")
|
|
msg = "The secret message said \"Open Sesame!\""
|
|
}
|
|
$print(msg, "\n", replaced = rot13(msg), "\n")
|
|
$print(rot13(replaced), "\n")
|