Problem with UTF8 files
am 23.04.2008 08:36:08 von 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
Re: Problem with UTF8 files
am 23.04.2008 10:45:08 von lexa
On Apr 23, 8:36=A0am, jmr wrote:
> 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:
> =A0 =A0 =A0 =A0 Dim sr As System.IO.StreamReader =3D New System.IO.StreamR=
eader(fname,
> Encoding.UTF8)
> =A0 =A0 =A0 =A0 Dim S As String =3D sr.ReadToEnd
> =A0 =A0 =A0 =A0 response.writel(S) 'NOTE THAT THE ACCENTED CHARS ARE OK HE=
RE
> =A0 =A0 =A0 =A0 sr.close()
> =A0 =A0 =A0 =A0 Dim w As System.IO.StreamWriter =3D New System.IO.StreamWr=
iter(fout,
> false, Encoding.Default)
> =A0 =A0 =A0 =A0 w.write(S)
> =A0 =A0 =A0 =A0 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.
Re: Problem with UTF8 files
am 23.04.2008 11:26:21 von jmr
Alexey Smirnov wrote:
> On Apr 23, 8:36 am, jmr wrote:
>
>>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.
Here is my web.config:
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
Re: Problem with UTF8 files
am 23.04.2008 14:35:55 von Martin Honnen
jmr wrote:
> 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.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Re: Problem with UTF8 files
am 23.04.2008 17:51:37 von jmr
Martin Honnen wrote:
> jmr wrote:
>
>> 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.
>
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