Caesar Cipher in Java (Spanish Characters)

Posted by Rodolfo on Stack Overflow See other posts from Stack Overflow or by Rodolfo
Published on 2010-06-14T12:32:59Z Indexed on 2010/06/14 13:12 UTC
Read the original article Hit count: 284

I've reading this question, and I was wondering if Is there any way to consider the whole range of characters? For example, "á", "é", "ö", "ñ", and not consider " " (the [Space])? (For example, my String is "Hello World", and the standard result is "Khoor#Zruog"; I want to erase that "#", so the result would be "KhoorZruog")

I'm sure my answer is in this piece of code:

if (c >= 32 && c <= 127)
        {
            // Change base to make life easier, and use an
            // int explicitly to avoid worrying... cast later
            int x = c - 32;
            x = (x + shift) % 96;
            chars[i] = (char) (x + 32);
        }

But I've tried some things, and it didn't work.

© Stack Overflow or respective owner

Related posts about java

Related posts about beginner