It's not a secret anymore!*
The moose likes I/O and Streams and the fly likes How can I get Unicode String of a String? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How can I get Unicode String of a String?" Watch "How can I get Unicode String of a String?" New topic
Author

How can I get Unicode String of a String?

Blood Bigsoon
Greenhorn

Joined: Jun 03, 2001
Posts: 13
Hi,I write a program now,but I can't get the right unicode string of the string,who knows that?Pls help me!Thx
eg:
String str = "abcd";
System.out.println(new String(str.getBytes("Unicode"));//But I can't get the right Unicode of the String if user this.
Sumeet Gaikwad
Ranch Hand

Joined: Mar 07, 2002
Posts: 37
Dear Blood,
I am not sure what you want with the unicode String? But if you want to read the unicode from the file then use the following code.

Hope this help.


Sumeet Gaikwad<br />SCJP, SCWCD<br />-----------------------------------------------------------------------------------<br />Nothing is impossible because it spells... I M Possible !!!
Blood Bigsoon
Greenhorn

Joined: Jun 03, 2001
Posts: 13
I got he right way.I switch the byte[2] and byte[1].sigh
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can I get Unicode String of a String?
 
Similar Threads
A strange unicode String literal problem
How to get unicode for a character?
Need unicode char
MSSQL: TO XML clause for ASCII format
dan exam dought