• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to specify foreign characters in hex form in Java?  RSS feed

 
Max Fan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
like,


But I can not display this string with a corresponding encoding... It just shows "x3451"

 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Unicode escapes.



That produces 㑑 which should be this Chinese character, which I assume was what you wanted?
 
Max Fan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Use Unicode escapes.



That produces 㑑 which should be this Chinese character, which I assume was what you wanted?


Thanks for reply. But why I got a "?" when I System.out.print("\u3451");

Should I explicitly set the encoding somewhere?
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because your console can't handle those characters. Don't waste any time trying to get the console to work, use a GUI or web interface to display them.
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bash shell happily accepts 㑑. The Windows® command line almost certainly won’t.

I think I ought to move this thread as too difficult for “beginning”.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!