Android Question International characters?

Troberg

Well-Known Member
Licensed User
Longtime User
I'm trying to display some text in a list. The text is read from a file using TextReader. It works nicely, except that international characters (in my case, å, ä, ö, Å, Ä, Ö) comes up as garbage. If I put the same characters in as constant strings in code, it works fine. If I check the codes using asc, they come up the same in the string constant as in the file (for example, å is 229).

So, my guess is that TextReader doesn't understand them. I'm going to do some more testing, but thought that I'd ask before I sink too much work into it.

Known issue? Workaround? Am I messing up?
 

klaus

Expert
Licensed User
Longtime User
The text is read from a file using TextReader.
How was the file created ?
If you created it on the PD it is probably encoded with "Widows-1252".
Android use UTF-8 encoding.
Try to either to:
- initialize TextReader.Initialize2(Path, FileName, "Windows-1252").
- save the file on the PC with UTF-8 encoding.
You might use Notepad++ there you have the option in the menu Encoding / Encoding UTF-8 without BOM.
If you save with BOM three characters are added at the beginning of the file.
Without BOM these characters are not added.

You could have a look at chapter 14.10.6 Text encoding in the Beginner's Guide.
 
Upvote 0

Troberg

Well-Known Member
Licensed User
Longtime User
It was just me being stupid. I had set the encoding after I entered the text, and, of course, that doesn't change the content of the file, just how it's displayed.

Now it works. Thanks!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…