Home arrow Java arrow Page 5 - J2ME and Unicode

J2ME and Unicode

javaIf you've ever run into problems faced with multi-lingual text differences, Jason's latest article will solve just that.  Learn how to make use of Unicode character-sets when developing in a J2ME-based environment, where you'll more than likely have a need to develop MIDlets in multiple languages.

Author Info:
By: Jason Lam
Rating: 5 stars5 stars5 stars5 stars5 stars / 99
December 26, 2003
  1. · J2ME and Unicode
  2. · Enabling the J2ME Emulator with Unicode
  3. · Simple Unicode Test
  4. · Read Unicode File
  5. · Reading a Text File with Unicode Codes
  6. · Conclusion

print this article

J2ME and Unicode - Reading a Text File with Unicode Codes
(Page 5 of 6 )

In the last section we went over reading a Unicode file.  An alternative approach is to read the text file with Unicode codes in them.  Referring back to the Hello World example the following would be inside the text file:


One would think this is very straight forward and that a simple load/read of the text would do.  However, when reading the file each character is treated as a string.  So in other words:


reads in as

, u, 3,0,5,3

You will now have to detect and parse out the u which indicates that the next four characters represent a Unicode character.  The following method will help convert the string to the appropriate Unicode character.  It assumes you are only passing in a valid four character Unicode (ie: 3053).

  private String convertStrToUnicode(String value) {
    short valueAsShort = Short.parseShort(value.trim(),16);
    return String.valueOf((char)valueAsShort);

blog comments powered by Disqus

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials