Possible Duplicate:
ROT-13 function in java?
I have to shift all char from a string 13 places in the alphabet
private static String encode(String line) {
char[] toEncode = line.toCharArray();
for (int i = 0; i < toEncode.length; i++) {
if (Character.isLetter(toEncode[i])) {
toEncode[i] += 13;
}
}
line = String.valueOf(toEncode);
return line;
}
The Problem is that for example 'z' get to a ?. How can I solve that?
Thx for help.