Strange encoding behaviour

A

Antonio

Hi Jon,
I have to say thanks, you solved my problem, the only question is
where did you see
that it was ISO-8859-1, I can't discover this while I'm interested
because I need to translate also to chinese
and this is not well done with ISO-8859-1.
Can you help me again ??
Many thans,

Engineer Antonio D'Ottavio
www.etantonio.it/en
(e-mail address removed)







The problem is that although the *page* claims that the content is in
UTF-8, it's not - it's actually in ISO-8859-1, which is what the
*headers* claim.

If you change your code to use Encoding.GetEncoding(28591) you'll get
the right result - but only for that particular page, of course...

--
Jon Skeet - <[email protected]>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too





Good Morning,
I've the following problem :

I want to translate some page of my site using babelfish translator of
Altavista,
To avoid manual job I want to deliver a c# script that produce this
result.

I've putted this page on my site at the url
http://www.etantonio.it/EN/Economia/indexTest.aspx

////////////////////////////////////////////////////////
<html>
<title>Economy</title>
</head>
<body>
<p align="center">Economy</p>
</body>
</html>
////////////////////////////////////////////////////////

If I try to translate this using altavista, the result is directly
available at
the url http://babelfish.altavista.com/babe...//www.etantonio.it/en/economia/indexTest.aspx
and it's working OK, the translation of Economy in French is Économie
, the problem is in the first letter of Économie
, the É is not well recognized instead by the following my c# script

///////////////////////////////////////////////////////////////////////////////
<%@ Page Language="c#" debug="true" trace="true"
ResponseEncoding="utf-8"%>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Net" %>
<script runat="server">
void Page_Load(Object Src, EventArgs E )
{
String sAddress =
"http://babelfish.altavista.com/babe...//www.etantonio.it/en/economia/indexTest.aspx"
;
WebRequest req = WebRequest.Create(sAddress);
WebResponse result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
StreamReader reader = new StreamReader(ReceiveStream, Encoding.UTF8
);
String sHtmlTradotto = reader.ReadToEnd();
Trace.Write("sHtmlTradotto", sHtmlTradotto);
}
</script>
///////////////////////////////////////////////////////////////////////////////


whose result is available at the url

http://www.etantonio.it/Utility/Traduzioni/TraduttoreAltavistaPaginaWebEnFrRidotto.aspx

and basically shows that the É of Économie is blanked.

How can I solve the problem and finally obtain this translation ??

I think the problem is not in the code because if I use it for this
other address string

String sAddress =
"http://www.etantonio.it/Utility/Traduzioni/FR.aspx" ;


Can you help me ???
Many thanks in any case ...

Engineer Antonio D'Ottavio
www.etantonio.it/en
(e-mail address removed)
 
J

Jon Skeet [C# MVP]

Antonio said:
I have to say thanks, you solved my problem, the only question is
where did you see
that it was ISO-8859-1, I can't discover this while I'm interested
because I need to translate also to chinese
and this is not well done with ISO-8859-1.
Can you help me again ??

I saw it in the header from the web-server, using the
WebResponse.ContentType property.
 

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