LWUIT HTMLComponent shows question marks on some samsung models

390 views Asked by At

I'm creating a mobile app using LWUIT. I used HTMLComponent to show help text to user. Note that the help language is Farsi (which uses Arabic letters).
On most handsets it works fine but on others (e.g. Samsung B3410W) it just shows questions marks instead of letters.
I've set HTMLCallback but parsingError is not called at all.
The instruction which sets the html code is this:

helpComponent.setHTML("<html dir=\"rtl\"><body><p align=\"justify\">" + body + "</p></body></html>", "UTF8", null, true);

where body is a string read by calling DataInputStream.readUTF() method.

Does any body know what I'm missing?

P.S. other parts of application(Lables, Forms, etc) has no major problems with arabic letters. It's just HTMLComponent which is problematic.

Thank you


I changed "UTF8" for encoding to "UTF-8" and now the problematic handset is working fine. It seems (at least some) samsung models use "UTF-8" as the name of that encoding.

But I'm worried that some other mobile handsets may have problem with "UTF-8" and accept "UTF8".

Is there any thing that I can do to make it working on all phones?

2

There are 2 answers

1
frayab On

It's probably the same problem: Why arabic font not supported in Samsung mobiles using LWUIT?

LWUIT doesn't support Arabic bitmap fonts, when the font type is 'system' we just delegate the Arabic support to the underlying OS. If the underlying phone OS doesn't include Arabic support LWUIT won't work with Arabic.

To workaround this some people have made efforts to implement Arabic bitmap fonts by modifying LWUIT to support that. We haven't incorporated any of these changes since:

a. They are very complex and language dependent. b. They don't solve the issue of accepting input. c. Most devices in Arabic speaking countries should support Arabic so its a pretty niche problem.

These solutions might be enough for your needs, but personally I wouldn't make the effort for that small fraction of devices.

1
Shai Almog On

These issues happen because of bad encoding. I'm guessing the data is already corrupted by the time you got to readUTF(). Make a simple experiment of creating a single character body that has a unicode value which you are having a problem with and printout the numeric value of the character to see whether it matches the unicode value you expect.