Java encoding question

Dear all,If i read some string from database which is of Big5, how can i transform those string into unicode?Thank you!
[140 byte] By [david1661a] at [2007-11-27 9:04:06]
# 1
If you are sure that the string encoded by Big5, you may use new String("xxxx".getByte("Big5"))
Stone.lia at 2007-7-12 21:36:51 > top of Java-index,Java Essentials,Java Programming...
# 2
Thank you!By the way, is there a way to verify a string's current encoding? e.g. how to verify if a string is containing some Big5 characters.Thanks!
david1661a at 2007-7-12 21:36:51 > top of Java-index,Java Essentials,Java Programming...
# 3

huh, I only have a stupid modus:

On debugging, watch the string on the ide. If the value of the string is what you need, then the encoding of the string is your local encoding.

more time-consuming modus is : get the code the string as '0x348A' and search the code table of BIG5, then check it as what you need.

Stone.lia at 2007-7-12 21:36:51 > top of Java-index,Java Essentials,Java Programming...
# 4
Thanks!How can get the string in the form of 0x348A ?Thank you!
david1661a at 2007-7-12 21:36:51 > top of Java-index,Java Essentials,Java Programming...
# 5

that is the HEX format of one word's byte[ ]. The '0x348A' is only a example.

e.g:

byte[] bs = "云".getBytes();

for(byte b : bs){

int n = b & 0xff ;

String s = Integer.toHexString(n);

if(s.length() == 1){

s = "0" + s;

}

System.out.println(s);

}

Stone.lia at 2007-7-12 21:36:51 > top of Java-index,Java Essentials,Java Programming...
# 6

If you have a String in Big5 in the database and the database is set to use Big5 as it's encoding correctly, then all you need to do is get it as a String from a resultset.

By then it will be in the memory as UTF-16 and you can write it out in any encoding you want in the standard way (using OutputStreamWriter).

-Kayaman-a at 2007-7-12 21:36:51 > top of Java-index,Java Essentials,Java Programming...