×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Unhappy Proper way of handling Arabic characters?

    Hi All,

    I have a LWUIT TextArea which accepts user input. After the user hits submit, the string that the user has inputted on the TextArea is saved on the disk. For this purpose, I do:

    Code:
    DataOutputStream daos = new DataOutputStream(baos);
    daos.writeUTF(name);
    ...
    byte[] data = baos.toByteArray();
    rec.addRecord(data, 0, data.length);
    to ensure that the string is encoded as UTF-8 before persisting it to disk. When reading it from disk, I do:

    Code:
    DataInputStream dais = new DataInputStream(bais);
    String name = dais.readUTF();
    to ensure that the string that was encoded as UTF-8 is properly read.

    My problem is, if the user inputs an Arabic string on the text area, it would display fine on the screen. Once the user hits submit and I try to read back the string that was saved and display it on the text area, it would not display correctly. Instead, what would be displayed are a bunch of 0's and squares instead of the original Arabic character that the user has inputted. However, if I use Unicode code points to represent a UTF-8 character instead (e.g. \u200f\u0645\u0648\u0627\u0641\u0642), it would display fine on the text area - and this is how I represent Arabic characters in my localization file. Any idea why is this the case? Can we only display Arabic characters on the screen if it is in Unicode code point?

    Many thanks!
    Jim

  2. #2
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Re: Proper way of handling Arabic characters?

    Never mind, I figured it out. When I was creating a String from a byte array, I did not specify what encoding I want it to be so it used the default encoding which made the entire thing incorrect.

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Proper way of handling Arabic characters?

    Yes and I would also suggest you use encoding when you call toByteArray("UTF-8") to make sure you save it there in the proper form.
    Heard of DVLUP? Join here

Similar Threads

  1. SMS sent in Arabic Language are receiving as some characters at other end.
    By pranay_preet in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2010-11-16, 10:59
  2. arabic characters
    By reshmy in forum Mobile Java General
    Replies: 1
    Last Post: 2008-08-24, 14:14
  3. Some bad Pashto(Arabic Alphabet) Characters in S60 p2
    By bcguitar33 in forum Mobile Java General
    Replies: 0
    Last Post: 2006-12-07, 21:08
  4. Arabic Characters
    By srikanth06 in forum General Messaging
    Replies: 4
    Last Post: 2003-05-04, 22:21
  5. SMS-ing with arabic characters
    By enternada in forum General Messaging
    Replies: 3
    Last Post: 2003-04-24, 22:15

Posting Permissions

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