0

I have opened up a file in Notepad++, and it displays the file as I expected it.

It shows the encoding as ANSI.

Now I tried to the same in in VB.NET using FileIO.TextFieldParser, but none of the Encoding constants resulted in the same (correct) reading of the text.

The encoding "Latin1" gave the closest results.

However, 1 character is still not as I expected it.

I am expecting a € character, but I got ChrW(128).

This is what I see when I hover over the string:

enter image description here

VS displays it as ChrW(128), so I guess it means that it sees it as something which can't be displayed normally (like vbLf, etc.), so something must be wrong.

Can anybody see what is going on here and how to fix it?

Edit:

Here is how I call it:

    Using tfp As New Microsoft.VisualBasic.FileIO.TextFieldParser(uPath, enc)
        s = tfp.ReadToEnd
    End Using
tmighty
  • 10,734
  • 21
  • 104
  • 218
  • See here: "ANSI" does not mean what you probably think it means: https://stackoverflow.com/questions/16083916/the-encoding-that-notepad-just-calls-ansi-does-anyone-know-what-to-call-it – Dai Oct 16 '22 at 19:39
  • Generic Comment - I do not know your specific situation. The VisualBasic.FileIO is desinged to give legacy compatibility - It is not exactly the same as typical behviors such as the more well defined System.IO . – Sql Surfer Oct 16 '22 at 21:11

0 Answers0