Στις 2/9/2013 2:38 μμ, ο/η Dave Angel έγραψε:
On 2/9/2013 00:16, Ferrous Cranus wrote:



Have you tried to decode those bytes in various encodings other than
utf-8 ?


No, because i wasn't aware of what string/variable they were pertaining at.



   http://pypi.python.org/pypi/chardet

is a package which tries to 'guess' an encoding for a string of bytes.
I happen to have the 2.7 version installed, but not the 3.x version, so
the following is in 2.7. Same thing should work in 3.3....

chardet.detect(b'\xb6\xe3\xed\xf9\xf3\xf4\xef\xfc\xed\xef\xec\xe1 
\xf3\xf5\xf3\xf4\xde\xec\xe1\xf4\xef\xf2')
{'confidence': 0.9638983132261467, 'encoding': 'windows-1253'}
print b'\xb6\xe3\xed\xf9\xf3\xf4\xef\xfc\xed\xef\xec\xe1 
\xf3\xf5\xf3\xf4\xde\xec\xe1\xf4\xef\xf2'.decode('windows-1253')
¶γνωστοόνομα συστήματος


I don't have a clue what it might be;  it's not English, and I don't
know whatever language it may be in.

Does that string make any sense to you?

Yes it does, it mean "Unknown Hostname"

The Linux 'file' utility thinks this string is in ISO-8859, so you might
want to try a decode('ISO-8859-1') as well.  (and maybe  ISO-8859-2, -3,
-4, and -5)

How did you test it? The utility afaik analyzes a file's encodings not string encodings.

ni...@superhost.gr [~]# file www/cgi-bin/files.py
www/cgi-bin/files.py: a /usr/bin/python script text executable


--
Webhost <http://superhost.gr>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to