How do I know that there are double-byte characters in s String?
Hi!
If I have a String that contain English and Chinese words,
How do I know that the String contain double-byte characters(Chinese words)?
Following is my method and the problem I suffered...
String A = "test(double-byte chinese)test";
byte B[] = A.getBytes();
if(A.length() != B.length)
System.out.print("String contains double-byte words");
else
System.out.print("String does not contain double-byte words");
If the String contains Chinese words,then A.length() will be smaller than B.length...
I run the program on Window NT workstation(Tradtional Chinese version) and it works...
Then I run the same program on Redhat 6.0(English version),
but the result was not the same as running on NT...
because A.length() always equal to B.length...
I guess that's because of Charset of OS...
But I don't know how to set the Charset of Linux...
Does anybody have other solution to my problem?
Any suggestion will be very appreciate!

