Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I get Unicode String of a String?

 
Blood Bigsoon
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Blood Bigsoon
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got he right way.I switch the byte[2] and byte[1].sigh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic