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.
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.
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
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?