Android Question Trouble reading text file containing special character ú

toby

Well-Known Member
Licensed User
Longtime User
My app reads a text file, line by line, which contains the special character ú (in "Dún Laoghaire", a province in Ireland). I use Notepad++ to edit and save the text file with either ANSI or UTF8 encoding, and both encoding yield same result.

After the following line of code is executed, the ú has been changed to "?" with solid background.
code to read text file:
    Dim text As List = File.ReadList(File.DirAssets,fileName)

What am I missing?


TIA
 
Solution
Thank you @DonManfred for trying to help!

The problem: the text file wasn't really saved with UTF8 encoding even though I selected UTF8 from encoding dropdown menu and Saved the file.

MY Solution: Use Notepad instead of Notepad++ for this purpose, select File, Save As, and specify UTF8 encoding, if not selected yet, then finally hit Save.

TIA

DonManfred

Expert
Licensed User
Longtime User
What about
B4X:
    Dim bytes() As Byte = File.ReadBytes(File.DirAssets,fileName)
    Dim fulltext As String = BytesToString(bytes,0,bytes.Length,"UTF-8")
    Dim lines() As String
    lines = Regex.Split(CRLF, fulltext)

Can you upload the file from your assets? Sure it is saved as UTF-8?
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
Thank you @DonManfred for trying to help!

The problem: the text file wasn't really saved with UTF8 encoding even though I selected UTF8 from encoding dropdown menu and Saved the file.

MY Solution: Use Notepad instead of Notepad++ for this purpose, select File, Save As, and specify UTF8 encoding, if not selected yet, then finally hit Save.

TIA
 
Upvote 0
Solution
Top