TextEncoding from File

Hey there, i want to read the right encoding from a text file (in this case .csv).
Atm i tried this:

[code]Dim c2 As String
Dim t22 As TextInputStream

t22 = TextInputStream.Open(file.File)

dim enc As TextEncoding = t22.Encoding[/code]

The problem is that in my case, i got a .csv File which is in ANSI-encoded, but Xojo says its UTF-8 encoded.
Whats the right way to get the TextEncoding from a file?

Thanks for answers!

Does the CSV have a BOM? What are you trying to do with the last line? That doesn’t make sense because you will just get the default encoding. You need to set the encoding manually if you don’t have a BOM:

t = TextInputStream.Open(f) t.Encoding = Encodings.ANSI-something TextArea1.Value = t.ReadAll

@Beatrix Willius is it possible to look for a BOM in TextInputStream?

It will (if it exists) be the first byte or two of the input stream. You could look up BOM in Wikipedia to see what it might be. But if there isn’t one, then as Beatrix says you have to set it manually.