[SOLVED] Android and Unicode

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

egolombek
Posts: 74
Joined: Thu Jan 30, 2020 2:11 pm

[SOLVED] Android and Unicode

Post by egolombek » Sun Jun 28, 2020 1:16 pm

I am working on my first Android App (as some of you know from my previous post :D )

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
Last edited by egolombek on Wed Jul 01, 2020 6:21 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Sun Jun 28, 2020 1:45 pm

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:
-
Screenshot 2020-06-28 at 15.36.04.png
-
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"
-
Screenshot 2020-06-28 at 15.44.28.png
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
Attachments
Moshe.livecode.zip
Here's the stack
(994 Bytes) Downloaded 120 times

egolombek
Posts: 74
Joined: Thu Jan 30, 2020 2:11 pm

Re: Android and Unicode

Post by egolombek » Sun Jun 28, 2020 1:51 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Sun Jun 28, 2020 2:00 pm

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7229
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Android and Unicode

Post by jacque » Sun Jun 28, 2020 4:06 pm

When you say it doesn't work, what happens? Do you see text? If so, what's wrong with it?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Sun Jun 28, 2020 5:30 pm

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

egolombek
Posts: 74
Joined: Thu Jan 30, 2020 2:11 pm

Re: Android and Unicode

Post by egolombek » Sun Jun 28, 2020 6:04 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7229
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Android and Unicode

Post by jacque » Sun Jun 28, 2020 8:50 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

egolombek
Posts: 74
Joined: Thu Jan 30, 2020 2:11 pm

Re: Android and Unicode

Post by egolombek » Mon Jun 29, 2020 5:05 am

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...

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Mon Jun 29, 2020 7:25 am

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)?

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Android and Unicode

Post by SparkOut » Mon Jun 29, 2020 7:47 am

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Mon Jun 29, 2020 10:14 am

Screenshot 2020-06-29 at 12.12.35.png
-
Hmm . . . it would be interesting to see what an Android build of that does. 8)
Attachments
Avram.livecode.zip
Here's the stack.
(1.46 KiB) Downloaded 130 times

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Android and Unicode

Post by Klaus » Mon Jun 29, 2020 10:22 am

FYI: I deleted the double posting in the ANDROID forum!

egolombek
Posts: 74
Joined: Thu Jan 30, 2020 2:11 pm

Re: Android and Unicode

Post by egolombek » Mon Jun 29, 2020 11:20 am

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:

Image


Help!!!! :shock:
Attachments
HebApp fail.jpeg

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Mon Jun 29, 2020 12:35 pm

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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”