×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    2

    Unhappy Need some help with Unicode on J2ME

    Hi Folks,

    I'm creating a J2ME application with multi-lingual text capabilities. I'm developing it with Sun WTK 2.2 for certain backward compatibility requirements.

    My J2ME client communicates with a server over WLAN/GPRS which responds back with a text stream. That response string could be in any script. As of now, it is encoded in Devanagari (Hindi). We are transliterating the Devanagari string to Roman script on the client. While the transliteration works fine on the desktop emulator with WTK 2.2, on the client it displays 'nullnullnullnullnull'.

    I'm doing a very simple transliteration. I load all the Unicode entity codes of Devanagari as keys and the corresponding letters in Roman as values in a Hashtable.

    For eg:
    Hashtable devanagariMap = new Hashtable(85);
    devanagariMap.put("2309","a");
    devanagariMap.put("2310","aa");
    devanagariMap.put("2311","i");
    devanagariMap.put("2312","ee");
    devanagariMap.put("2313","u");
    devanagariMap.put("2314","oo");
    devanagariMap.put("2315","ri");
    .... and so on ....

    I'm using simple integer entity codes. I know I can use Hex codes too.

    I then decode the response string by reading the individual characters. Then I get the integer values of those characters and get their Roman equivalent from the Hashtable.

    It works fine on Desktop emulator. But on the mobile (I'm using Nokia N95) it fails and just displays 'nullnullnullnullnullnull...'. Can anyone give me some pointer on this?

    I suspect maybe its a mismatch between the desktop emulator JVM and the N95 JVM. But not sure. Can someone please give me some pointers? I can provide more details if you require.

    Thanks in advance!

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,104
    Do you specify the correct encoding for your Internet streams?

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    2

    Re: Need some help with Unicode on J2ME

    Thanks!

    But, I'm not sure how much of that J2SE could be transferred to J2ME. Anything specific for J2ME? Thanks.

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Need some help with Unicode on J2ME

    How is the array of bytes from the server converted to a String?

    If you're doing this:

    Code:
    String s = new String(byteArray);
    This will behave differently on different devices, depending on what encoding scheme the device uses to translate bytes to characters. Specify the encoding you are using. For example:

    Code:
    String s = new String(byteArray, "UTF-8");
    Graham.

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,104
    Quote Originally Posted by cyrao View Post
    I'm not sure how much of that J2SE could be transferred to J2ME.
    100% because if you know that J2SE stuff, you know how to do it in J2ME, too: You have to change byte streams into character streams through providing an encoding. Please, first go through that trail completely. Then come back, if you still have problems.
    Last edited by traud; 2010-02-19 at 15:47.

Similar Threads

  1. Acessing voice channel using J2ME
    By diegomello in forum VoIP
    Replies: 1
    Last Post: 2008-10-21, 15:57
  2. Display unicode character in j2me application
    By munzur in forum Mobile Java General
    Replies: 1
    Last Post: 2008-06-18, 09:03
  3. Porting BlackBerry: Carbide & J2ME Comparison.
    By skynetchris in forum Symbian C++
    Replies: 0
    Last Post: 2008-05-22, 07:09
  4. Can J2ME be used for sending MMS Message ?
    By seno_ap in forum Mobile Java General
    Replies: 1
    Last Post: 2006-11-24, 14:36
  5. need urgent guidance on j2me
    By cogni_niru in forum Mobile Java General
    Replies: 1
    Last Post: 2005-11-13, 15:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •