×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    5

    Handling text direction

    I have a problem I hope someone can help with. My MIDlet lets the user enter some text and then I display it in a Canvas using drawString. I use a basic word wrap algorithm to handle longer, multi-line text, nothing fancy. Everything is fine except if the user enters text in languages that are written right-to-left. Say the user enters some Hebrew or Arabic, I want to know this and thus right-align the text when drawn.

    My question is, how can I detect whether the user's input is a right-to-left or a left-to-right language? I just want to know which text to left-align and which to right-align, since the user can enter any string into the input. Any suggestions?
    Last edited by iyuen; 2007-03-22 at 00:47.

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,430

    Re: Handling text direction

    You could use System.getProperty("microedition.locale") to identify the phone's current locale.

    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    5

    Re: Text Direction issue with displaying strings

    Ok, but it doesn't tell me what text the user has input. The phone may be set to one locale, but the user can still enter something different. Right?

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    62

    Re: Text Direction issue with displaying strings

    Quote Originally Posted by iyuen
    Ok, but it doesn't tell me what text the user has input. The phone may be set to one locale, but the user can still enter something different. Right?
    Interesting problem.

    How about this approach: You could examine the String object the user has entered and scan through it character by character. If the characters belong to the range that Hebrew characters are in (looking at the hexadecimal Unicode values from http://www.unicode.org/charts/PDF/U0590.pdf), then the string is Hebrew and should be displayed right-to-left, ie. aligned to the right.

  5. #5
    Registered User
    Join Date
    Jan 2004
    Posts
    5

    Re: Text Direction issue with displaying strings

    Quote Originally Posted by knorring
    How about this approach: You could examine the String object the user has entered and scan through it character by character. If the characters belong to the range that Hebrew characters are in (looking at the hexadecimal Unicode values from http://www.unicode.org/charts/PDF/U0590.pdf), then the string is Hebrew and should be displayed right-to-left, ie. aligned to the right.
    That sounds feasible, I'll give it a shot! If someone has a more elegant approach, please let me know.

Similar Threads

  1. Replies: 0
    Last Post: 2005-11-02, 18:33
  2. Series 80 Chinese text displaying problem
    By arongpan in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-10-21, 05:00
  3. Replies: 0
    Last Post: 2004-11-24, 18:49
  4. Displaying large amounts of text?
    By ke2408 in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-06-18, 13:20
  5. Replies: 0
    Last Post: 2002-07-24, 16:11

Posting Permissions

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