Android Question Accented characters encoding

MitchBu

Well-Known Member
Licensed User
Longtime User
I usually code in English, so I never encountered this before.

Now I want to set an EditText's hint as French "Bénéficiaire", and I get black lozenges.

Bénéficiaire.jpg


I am sure the solution is simple. I simply don't know.I searched the forum unsuccessfully.

Any help will be most appreciated.
 

MitchBu

Well-Known Member
Licensed User
Longtime User
I am still working on the issue.

As it happens, I store messages in a keyValueStore. I store UTF8, but when I pull the value from the KeyValueStore, encoding is messed up and I get these abnormal characters in lieu of accented characters.

I could not find any way in the forum to set the encoding of a string.
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
I searched the forum right and left with "UTF8" but found no way to reinstate UTF-8 encoding when retrieving a string from the keyValueStore.

In another language (Xojo), I can use DefineEncoding to set the proper encoding when retrieving from a database.

I could not find any such thing in B4A.
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
The problem comes from reading a text file.

I have all the messages in English, French and Spanish in a Text file, which is loaded at the program start, and put into the KeyValueStore.

It appears B4A does not seem able to load correctly a text file created with Notepad, when it contains accented characters.

I tried both File.ReadString and TextReader. No luck.
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
In effect. I tend to use Notepad++ often. I never realized I could choose the encoding.

Now my language support is complete. It is nice to see the app change display when preferences are changed.

Thank you Klaus :)
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
UTF-8 is great, mate. ?

I especially appreciate that ASCII is "automatically" UTF-8. It's like somebody slipped that bonus in on purpose.

Actually, that is true in B4x, as well as in macOS, and perhaps Linux. But Windows by default is ANSI. Consequently Notepad.

I should have remembered that.
 
Upvote 0
Top