German characters not showing up when imported to listbox

I’m importing a UTF-8 encoded text file line by line into a listbox. Where there German characters such as an umlaut, that character is not displayed in the listbox, nor is any character that follows it. However, when I export again to a text file, the complete line including the umlaut gets exported, so apparently it’s in there, but is just not being displayed. I tried adding the encoding to the folderitem (shouldn’t have to), but that didn’t help.

If f <> Nil Then t = f.openAsTextFile t.Encoding = Encodings.UTF8

If i import the line: Vielen Dank für die Kolonien und die Sklaverei
I only see Vielen Dank f in the listbox, but the whole line shows up when I export each line to a new text file.

Try copying that string into a string variable and adding that to the listbox. It may be an issue reading the string in from a file.

Could it be the file is not UTF-8?

The file is definitely UTF-8. I resaved it using that encoding. Each line is being copied to a string variable (lineText) then added to an array prior to being added to the listbox… if t <> nil then do lineText = t.readLine lineArray.append lineText loop until t.EOF
It does go into another array after it gets sorted as to which type of line it is for proper processing. Some lines are text and some are numbers. Kind of convoluted (especially the way I write code) to show the whole method.

Can you provide test project and test file?
Just to reproduce it here?

I have no problem filling in utf8-textlines into an array and then in a listbox using this code, umlauts are preserved:
Which version of Xojo are you using?

Dim f as FolderItem
Dim lineArray() as String
Dim t as TextInputStream


f=GetOpenFolderItem("")

If f.Exists then
  t=TextInputStream.Open(f)
  //t=f.openastextfile
    
  Dim lineText as string
  
  if t <> nil then
    
    do
      lineText = t.readLine
      lineArray.append lineText
    loop until t.EOF
     
    Dim i as integer
    
    For i=0 to UBound(lineArray)
      Listbox1.AddRow(lineArray(i))
      
    Next
    
  End if
  
End if

2011 v 4.3

You may try Xojo 2017r1.1* just to be sure it is not the version you are using (and do not save the project while on Xojo 2017r1.1)

  • If you can. Else, try a little older version.

2011r4.3 does not run at all on my system, but the code with version 2012r2.1 was running ok (on macOS Sierra).

I have many problems with “German Umlauts” with Xojo 2017r1.1 when I’m using 64 bit.
Switching back to 32 bit solved it. [In 2017r2 this will be fixed with the 64bit-version.]

Perhaps you use 64bit at the moment? Can you try to switch to 32bit? And try it again?

Good idea, but version 2011r4.3 which Patrick is using does not support 64 bit.

Well, Xojo 2011 does read/write UTF-8 files just fine.
I can only expect some bug in the code from Patrick or a file which is not correctly encoded.