How to check double byte characters
807603Dec 3 2007 — edited Dec 3 2007Hi
My requirement: I have to accept the string (may include double byte characters and special characters). Need to check that wether that string contains any special characters(like %,&,..), if so should display error message.
My solution: Starting i tried by usign the ASCII values. But the my code dividing the Double Byte characters into two characters.
Code:
package JNDI;
public class CharASCIIValues {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s = args[0];
char ch[] = s.toCharArray();
for(int i=0;i<=ch.length;i++){
System.out.println(" "+ch[i]+"="+(int)ch);
}
}
}
I ran with some double characters (japanese)
But i got the out put was = ?=63 ?=63 ?=63 ?=63 ?=63 ?=63 1=49 2=50 3=51 h=104 e=101 l=108 l=108 o=111
The ? are double byte charcters.
Queries:
Do i need to set any java setting to support DB characters.
Please help me to come out this problem....any help/information will be appreciated.