unicode conversion to UTF-16

try{

String stringValue ="abc\u5639\u563b";

byte[] valueInUTF8 = stringValue.getBytes("UTF-8");

stringValue =new String(valueInUTF8,"UTF-8");

System.out.println(string);

}

catch (Exception e){//UnsupportedEncodingException

e.printStackTrace();

}

current output :- abc?

how can i print it properly in UTF format?

[728 byte] By [rohithtpa] at [2007-11-27 7:10:19]
# 1

> current output :- abc?

> how can i print it properly in UTF format?

Are you referring to the trailing question marks? If so, this is probably not a Java UTF conversion problem, but rather a problem with your shell/terminal. Try to determine which encoding and font is set for your shell/terminal and whether these support glyphs for \u5639 and \u563b.

thomas.behra at 2007-7-12 19:01:48 > top of Java-index,Java Essentials,New To Java...
# 2

The tranformationString stringValue = "abc\u5639\u563b";

byte[] valueInUTF8 = stringValue.getBytes("UTF-8");

stringValue = new String(valueInUTF8, "UTF-8");

does nothing except use up memory and CPU cycles. The original content of 'stringValue' is UNICODE characters. The updated 'stringValue' will contain exactly the same characters as the old 'stringValue'.

sabre150a at 2007-7-12 19:01:48 > top of Java-index,Java Essentials,New To Java...