• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unicode

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
Can anyone point me in direction of java classes that handle unicode strings ?
Basically I need to convert a unicode string like for example <FEFF004100420043> into a human readable sequence of chars. This string will translate to <ABC>.
The particular problem I have is to convert japanese unicode strings into japanese chars.
Thanks,
Steve Matthews
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since all Java Strings use Unicode internally, I'd call this a hexadecimal representation of Unicode values. Perhaps the simplest approach is to break it up into groups of 4 chars (each representing 1 char, e.g. "0041" = 'A'). Then use Integer.parseInt(str, 16) to convert a 4-char hexadecimal String str into an equivalent integer, and then cast it to single char. Collect the newly-parsed chars in a StringBuffer or something.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an excellent book in Internationaliztion (I18N), it should have some good informatoin/ideas about dealing with Japanese characters and other things you need ot be aware of (double byte stuff)
Java Internationalization (O'Reilly) by Deitsch and Czarnecki
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "to convert a unicode string like for example <FEFF004100420043> into a human readable sequence of chars"? Is FEFF004100420043 a symbolic representation of your string or hexadecimal? If it's simply a Unicode string, then you need a font that is capable of representing used set of characters (Japanese in your case).
If I understand right, parsing you will need if FEFF004100420043 is, say, ASCII-coded string representing a Unicode string?
Parsing "Unicode strings" can be tricky. FEFF for example is not a Unicode character, it is the Byte Order Mark, serving to indicate endianness. You can safely drop it. And are you sure it's always two bytes per character?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic