[Web-SIG] Encoding

Robert Brewer fumanchu at amor.org
Sat Mar 18 19:21:19 CET 2006


Mohamad Babaei wrote:
> I'm working on a program that fetches some translated
> texts from *Altavista online translator , *it works
> fine with languages like German, french & .. but it
> can not get translated text in Japanese or Russian
> or chinese. my code is something like this:
> 
> data1 = urllib.urlopen('http://www.babelfish.
>   altavista.com/babelfish/trurl_pagecontent?
>   lp=en_ru&url=http://www.google.com').read()
> data1=data1.decode('utf-8')
> f=open('/usr/local/new/tt.html','w')
> f.write(data1.encode('utf-8'))
> f.close()

1. Have you examined the response headers on a request for Japanese content and verified that the response is encoded in UTF-8?
2. Why decode it just to turn around and encode it again with the same encoding?


Robert Brewer
System Architect
Amor Ministries
fumanchu at amor.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/web-sig/attachments/20060318/f0c85399/attachment.htm 


More information about the Web-SIG mailing list