Page 1 of 2
[SOLVED] Android and Unicode
Posted: Sun Jun 28, 2020 1:16 pm
by egolombek
I am working on my first Android App (as some of you know from my previous post

)
My latest problem that I am stuck on is that Android is not displaying Hebrew text. I use encode and decoding RTF-8 to store and recover from a mySQL database and this works well on the desktop versions. But, for some reason it does not work on Android (same code). This leads me to wonder if I am missing some inclusion... but I cannot figure what it would be.
Any help from this amazing forum of kind geniuses would be most welcome.
Thank you!
>>> Problem solved -- see final post for instructions on using Hebrew for Android
Re: Android and Unicode
Posted: Sun Jun 28, 2020 1:45 pm
by richmond62
I hope this doesn't send you to sleep, but to be fair I learnt a bit of Hebrew 40 years ago on a kibbutz near Ashqelon
and have done nothing further since then:
-
-
The first field "I want to go to sleep" was filled in manually, using a Hebrew keyboard layout on a Macintosh computer.
The second field had text entered like this:
Code: Select all
on mouseUp
put empty into fld "gg"
put numToCodePoint(0x05D0) after fld "gg"
put numToCodePoint(0x05E0) after fld "gg"
put numToCodePoint(0x05D9) after fld "gg"
end mouseUp
Sorry, I really am feeling sleepy, hence only one word, but you should get the point.
Now, I don't know all that much about databases, but I wonder how the encoding and decoding works . . .
BUT I don't know what you mean by "RTF - 8"
-
I assume (?) that what is coming from the database is some sort of binary data, so wonder if you mean "UTF-8".
>>>>>>>>>
viewtopic.php?t=29068
Re: Android and Unicode
Posted: Sun Jun 28, 2020 1:51 pm
by egolombek
Sleepy indeed -- cute!
Yes, not RTF-8, Should be UTF-8 -- a typo.
In any case, I read in a UTF-8 encoded message from a database and use textDecode to then place it in a field. It works on desktop but not on Android.
function tidyD qID,colName
put revDatabaseColumnNamed (qID,colName) into tNam
put textDecode (tNam,"UTF-8") into tNam
return tNam
end tidyD
Re: Android and Unicode
Posted: Sun Jun 28, 2020 2:00 pm
by richmond62
There was a time when everything in the LiveCode documentation was badged as to which operating systems
it would work on . . .
I must say I wonder about Android and textDecode.
Re: Android and Unicode
Posted: Sun Jun 28, 2020 4:06 pm
by jacque
When you say it doesn't work, what happens? Do you see text? If so, what's wrong with it?
Re: Android and Unicode
Posted: Sun Jun 28, 2020 5:30 pm
by richmond62
I suspect the OP means that the data is not rendered as Hebrew text but something meaningless.
Might not be a bad idea to take a look over this way:
viewforum.php?f=53
Re: Android and Unicode
Posted: Sun Jun 28, 2020 6:04 pm
by egolombek
Right, I get something meaningless, and strangely, only a few characters long when the original is several lines long.
I will try posting in the Android Deployment area -- thanks for the idea.
E
Re: Android and Unicode
Posted: Sun Jun 28, 2020 8:50 pm
by jacque
I haven't ever needed to do this, but it looks like you will need a custom manifest file for the Android app. The manifest instructs Android to support RTL text.
<
https://android.jlelse.eu/rtl-support-o ... 3f2df512e2>
That article covers several different aspects of RTL display, but you may only need the first couple that deal with text.
Re: Android and Unicode
Posted: Mon Jun 29, 2020 5:05 am
by egolombek
First of all, thank you! I appreciate the ideas.
I am way out of my league when it comes to writing a manifest file. I didn't even know there was such a thing and would not know how to go about making one. I would try to figure it out, but really, from the article, that seems to be more about supporting RTL functionality. And while Hebrew is RTL, the problem seems to be before that with decoding. In other words, if it was an RTL issue, the text would appear, but backwards.
Still looking for ideas...
Re: Android and Unicode
Posted: Mon Jun 29, 2020 7:25 am
by richmond62
Still looking for ideas...
At the risk of insulting you:
Have you tried other encodings (UTF-16)?
Is it possible that you could supply 'us' here with a line of the binary data (to 'play' with)?
Re: Android and Unicode
Posted: Mon Jun 29, 2020 7:47 am
by SparkOut
I had an app (desktop based) the client used for captioning and headline tickers on a TV station in Iran. There would be lines of text in English in text files that translators would type in the Farsi version. This worked perfectly on screen but highlighted the fact that text is not always the same on different systems and even different applications on the same system. Specifically it was necessary to include a byte order marker, so that the big-endian or little-endian decision was made for the target without the target having a chance to get the codepoint bytes twisted around.
So not sure if it's helpful, but could be another area to check.
Some sample data would indeed be good if possible.
Re: Android and Unicode
Posted: Mon Jun 29, 2020 10:14 am
by richmond62
-
Hmm . . . it would be interesting to see what an Android build of that does.

Re: Android and Unicode
Posted: Mon Jun 29, 2020 10:22 am
by Klaus
FYI: I deleted the double posting in the ANDROID forum!
Re: Android and Unicode
Posted: Mon Jun 29, 2020 11:20 am
by egolombek
So, Richmond62... I appreciate your efforts!
Unfortunately, putting the stack you sent on Android only highlighted the problem. For one thing, you cannot see the Hebrew typing in the top field. Still, I typed blindly אני אוהב גלידה (I like ice cream). But most troubling... none of the decodings put it back together:
Help!!!!

Re: Android and Unicode
Posted: Mon Jun 29, 2020 12:35 pm
by richmond62
For one thing, you cannot see the Hebrew typing in the top field.
How about setting the
fontLanguage to Hebrew?
Then you can ensure that when a stack is exported to Android it will select a Hebrew font rather than the generic nonsense.