0
This kind of question has been asked before, but I wanted to make it more specific. The linked question asks to read from stdin and rot13 the input. I don't want the disadvantage of I/O code that differs a lot for each language in length.
The challenge:
Write a function that will ROT13 (wiki link) one char (as defined by the ASCII table).
No built-in ROT13 functionality allowed.
Shortest code wins.
You can use this kind of C-family loop to test your function:
for (int i = '!'; i <= '~'; ++i)
{
char c = (char) i;
System.out.println(c + " -> " + f(c));
}
@Howard: I linked that question myself. But that is different. Here the task is to rotate only one char. – Martijn Courteaux – 2014-01-02T17:49:23.803
The difference is minor only - almost all answers from the other question can be user with litte modifications. – Howard – 2014-01-02T17:50:00.097
@Howard: The most important difference is that I don't want the I/O code here. Just the plain algorithm. – Martijn Courteaux – 2014-01-02T17:52:06.067
2In my opinion changing I/O doesn't justify a new question in this case. – Howard – 2014-01-02T17:55:56.947