Danish chars disapere when reading from files (ÆØÅ)

nicolas_image
nicolas_image used Ask the Experts™
on
Im having a problem with reading a file with the special danish chars: Æ, Ø and Å

I have a file contining the following line:

Det er en test af æøå og ÆØÅ nemlig

But when I read it with the following code, it only reads then following:

"Det er en test af  og  nemlig"

As you can see it cuts out the danish chars.  Should I set up some kind of encoding?

Here are my code:

        Dim myWriter As StreamWriter
        Dim myReader As StreamReader
        Dim InString As String
        Dim infile As File
        Dim outfile As File

        myReader = infile.OpenText("c:\names.OLD")
        myWriter = outfile.CreateText("c:\names.txt")

        InString = myReader.ReadLine 'No ÆØÅ are read
        While Not InString Is Nothing
            myWriter.WriteLine(InString)

            InString = myReader.ReadLine

        End While
        myWriter.Close()
        myReader.Close()


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Replace your line

myReader = infile.OpenText("c:\names.OLD")

with

myReader = New StreamReader("c:\names.OLD",Encoding.Default)

Hope this helps.
Thanks for accepting, but....

Grade 'b' ??

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial