469,623 Members | 1,003 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Strange encoding behaviour

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/babel...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/babelfish/trurl_pagecontent?doit=done&tt=url&intl=1&lp=en_fr &url=http%3A%2F%2Fwww.etantonio.it%2Fen%2Feconomia %2FindexTest.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/Trad...FrRidotto.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
po********@etantonio.it
Nov 16 '05 #1
2 1641
How does the string look when you run it through the debugger?
Nov 16 '05 #2
Antonio <et*******@libero.it> wrote:
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.


<snip>

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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Sebastian Meyer | last post: by
2 posts views Thread by Juho Vuori | last post: by
1 post views Thread by Sam | last post: by
1 post views Thread by Antonio | last post: by
9 posts views Thread by Mark | last post: by
3 posts views Thread by CyberSpyders | last post: by
8 posts views Thread by Dox33 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.