RosettaCodeData/Task/Rot-13/TorqueScript/rot-13.torque

23 lines
422 B
Plaintext

function rot13(%string)
{
%alph = "abcdefghijklmnopqrstuvwxyz";
%len = strLen(%string);
for(%a = 0; %a < %len; %a++)
{
%char = getSubStr(%string,%a,1);
%pos = striPos(%alph, %char);
if(%pos < 0)
%out = %out @ %char;
else
{
if(strPos(%alph, %char) < 0)
%out = %out @ strUpr(getSubStr(%alph, (%pos + 13) % 26));
else
%out = %out @ getSubStr(%alph, (%pos + 13) % 26);
}
}
return %out;
}