I am writing an application that must generate a plain Text file with fixed sized columns.
my current code is:
Dim MyFilePath As String = Path & FILE_PREFIX & FileNr & ".TXT"
IO.File.Delete(MyFilePath)
Dim FileStr As New IO.StreamWriter(MyFilePath, False, <ENCODER HERE>)
Do While r.Read
FileStr.WriteLine(r("TXTLine"))
Loop
FileStr.Close()
r.Close()
My problem is that i have some special characters like: "ñ", "à", etc, and i can't find the right encoding.
- If i use default, then it replaces "ñ" with 2 characters.
- If i use ASCII then all special Characters end up as: "?"
- If i use UTF-8 then all text is ok, but it add a "ÿ" in the first byte of the file.
I need the special characters to be writed in the textfile just as they came in the datareader. And i can't have extra characters added becouse columns are of fixed lenght..
What could i do?
Thanks in advance.