Read ANSI text file

  • Thread starter Thread starter Nikolay Petrov
  • Start date Start date
Use one of the StreamReader constrcutor overloads that accepts encoding
parameter. The default is UTF-8.

HTH.

How to read ANSI text.
The sream reader reads only UTF-8
 
Nikolay,
Use the overloaded StreamReader constructor that accepts an encoding object.

Something like:

Imports System.IO
Imports System.Text

Dim reader As New StreamReader("myfile.txt", Encoding.Default)

For output you could use:
Dim writer As New StreamWriter("myfile.txt", False, Encoding.Default)

Encoding.Default represents the ANSI code page that is set under Windows
Control Panel.

For a more specific ANSI code page you could use Encoding.GetEncoding.

For information on Encodings, Unicode & such see:

http://www.yoda.arachsys.com/csharp/unicode.html

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top