Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to check double byte characters

807603Dec 3 2007 — edited Dec 3 2007
Hi

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.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 31 2007
Added on Dec 3 2007
3 comments
2,191 views