write special chars to textfile

S

Snuyt

Hello,

I try to export some text to a textfile. But when I use special
characters such as é, à, è, ... I get some weird characters in the
resulting file:

"saisonnières et thématiques." instead of "saisonnières et thématiques."

Here is the code:

Dim line, filename As String
Dim myStreamWriter As StreamWriter
filename="test.txt"
myStreamWriter = File.CreateText(filename)
line="the text which is written to the textfile"
myStreamWriter.WriteLine(line)
myStreamWriter.Flush()

Does anyone knows a solution to this problem

Thanks,

Snuyt
 
H

Herfried K. Wagner [MVP]

* Snuyt said:
I try to export some text to a textfile. But when I use special
characters such as é, à, è, ... I get some weird characters in the
resulting file:


"saisonnières et thématiques." instead of "saisonnières et thématiques."

Here is the code:

Dim line, filename As String
Dim myStreamWriter As StreamWriter

\\\
Dim fs As New FileStream(...)
Dim MyStreamWriter As New StreamWriter(fs, Encoding.<...>)
///

Replace the '<...>' with the encoding you want to use that includes the
characters.
 

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

Top