×

Discussion Board

Results 1 to 5 of 5

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Malaysia-Johor-Pontian Kecil
    Posts
    163

    Using canvas to display unicode.

    Hi,
    I'm using canvas to display unicode, my code is like that:
    g.drawString(new String("\u9879\u76ee".getBytes(), "UTF-8"), 0, 0, 0);
    But I don't know what's going on. I can see the rectangle words only. Please guide me how to solve it. Thanks.

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    If you're using an emulator then it might just be that the emulator doesn't support (or is not set up to) the language. Rectangles are often shown when the language isn't supported. Try it out on a real phone (that has that language's font installed of course).
    I usually just print out text like this:
    Code:
    g.drawString("\u9879\u76ee", 0, 0, 0);
    with no problems at all.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Location
    Malaysia-Johor-Pontian Kecil
    Posts
    163
    Hi,

    The emulator is ok (The real device, Nokia7650, is ok as well). I can see the chinese words in List component and title. But only the canvas as such problems. Please guide me how to solve it. Thanks.

  4. #4
    Regular Contributor
    Join Date
    Mar 2003
    Location
    USA
    Posts
    90

    Unicode format wrong

    your unicode escape sequences are wrong..

    Remember UTF-8 unicode escape sequence should look like this..

    first it takes three unicode escape sequences for each character not two..

    Second..

    because of the amount of recognized sequences you should be seeing leeadin zeros..

    for example:

    New Game in greek is:

    \u00CE \u009D \u00CE \u00AD \u00CE \u00BF \u00CF \u0080 \u00CE \u00B1 \u00CE \u00B9 \u00CF \u0087 \u00CE \u00BD \u00CE \u00AF \u00CE \u00B4 \u00CE \u00B9

    notice that the mulitple of 3 matches the exact original characters in greek..

    what character seq are you trying to display from what language encoding?

  5. #5
    Registered User
    Join Date
    Mar 2003
    Location
    Malaysia-Johor-Pontian Kecil
    Posts
    163
    Hi,

    Thank for your reply.

    I'm going to display Chinese GB. And the unicode is translated by native2ascii (encoding: MS936, Windows Simplified Chinese
    ), according to

    http://java.sun.com/j2se/1.3/docs/gu...oding.doc.html

    I'm not understanding by the " three unicode escape sequences" u mean. Can you explain the detail ? And how should I do to generate the unicode ?

    Thanks.

    Best Regards,
    chai.

Posting Permissions

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