Android Question Reading Spanish files

aedwall

Active Member
Licensed User
Longtime User
I am trying to read text from a Spanish language file and display parts of that text in an EditText control. I can read in the text, but it displays black diamonds with question marks when any accented character is found. What is the solution in order to see proper accented characters in my EditText control? Thank you.
 

aedwall

Active Member
Licensed User
Longtime User
This does not seem to work:
B4X:
    txt = File.ReadString(File.DirAssets, filename)        'text in Spanish
 
    Dim arrByte() As Byte
    Dim result99 As String
    arrByte = txt.GetBytes("Windows-1252")
    result99 = BytesToString(arrByte, 0, arrByte.Length, "UTF8")
    
    txt = result99

So I guess I have to somehow do some conversion when reading the file itself. Perhaps .ReadString is not the right command to use.
 
Upvote 0

aedwall

Active Member
Licensed User
Longtime User
So I think I found the solution (for folks who later ask similar questions):

B4X:
    'txt = File.ReadString(File.DirAssets, filename)
 
    Dim arrByte() As Byte
    Dim result99 As String
    arrByte = File.ReadBytes(File.DirAssets, filename)

    'arrByte = txt.GetBytes("Windows-1252")
    result99 = BytesToString(arrByte, 0, arrByte.Length, "Windows-1252")
 
Upvote 0
Top