Problem with UTF8 files

J

jmr

Hi All,

I'm trying to read an UTF8 encoded file and write it with Encoding.Default.
The problem is that the accented characters in the output file are not
good when I open the file using an editor. I have question marks e.g
Bezenc?on.

Here is the code I use:
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(fname,
Encoding.UTF8)
Dim S As String = sr.ReadToEnd
response.writel(S) 'NOTE THAT THE ACCENTED CHARS ARE OK HERE
sr.close()
Dim w As System.IO.StreamWriter = New System.IO.StreamWriter(fout,
false, Encoding.Default)
w.write(S)
w.Close()

Any idea ?

Thanks,
Jean-Michel
 
G

Guest

Hi All,

I'm trying to read an UTF8 encoded file and write it with Encoding.Default..
The problem is that the accented characters in the output file are not
good when I open the file using an editor. I have question marks e.g
Bezenc?on.

Here is the code I use:
        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(fname,
Encoding.UTF8)
        Dim S As String = sr.ReadToEnd
        response.writel(S) 'NOTE THAT THE ACCENTED CHARS ARE OK HERE
        sr.close()
        Dim w As System.IO.StreamWriter = New System.IO.StreamWriter(fout,
false, Encoding.Default)
        w.write(S)
        w.Close()

Any idea ?

Thanks,
Jean-Michel

What is your Encoding.Default? Use Encoding.UTF8 instead, or set it in
the globalization tag of the web.config file.
 
J

jmr

Alexey said:
What is your Encoding.Default? Use Encoding.UTF8 instead, or set it in
the globalization tag of the web.config file.

Here is my web.config:
<globalization
fileEncoding="iso-8859-1"
requestEncoding="iso-8859-1"
responseEncoding="UTF-8"
/>

The problem is that I don't want to write the file with Encoding.UTF8
because I cannot read it with text editors (Notepad, scite, ..)

Thanks,
Jean-Michel
 
M

Martin Honnen

jmr said:
The problem is that I don't want to write the file with Encoding.UTF8
because I cannot read it with text editors (Notepad, scite, ..)

I don't know scite but Notepad can certainly deal with UTF-8 encoded
documents.
 
J

jmr

Martin said:
I don't know scite but Notepad can certainly deal with UTF-8 encoded
documents.

Scite is also supposed to read UTF-8 documents but with this specific
file, it cannot display accented characters (same for notepad). If I
open this file with a browser or wordpad, that's ok. This seems very
strange to me.

Jean-Michel
 

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

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top