Java
  Home arrow Java arrow Page 5 - J2ME and Unicode
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

J2ME and Unicode
By: Jason Lam
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 87
    2003-12-26

    Table of Contents:
  • J2ME and Unicode
  • Enabling the J2ME Emulator with Unicode
  • Simple Unicode Test
  • Read Unicode File
  • Reading a Text File with Unicode Codes
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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:

    u3053u3093u306Bu3061u306Fu4E16u754C

    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:

    u3053

    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);
      }

    More Java Articles
    More By Jason Lam


     

    JAVA ARTICLES

    - 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 ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway