Changing filenames from Greeklish => Greek (subprocess complain)

Νικόλαος Κούρας nikos.gr33k at gmail.com
Sun Jun 9 05:38:13 EDT 2013


Τη Κυριακή, 9 Ιουνίου 2013 12:20:58 μ.μ. UTC+3, ο χρήστης Lele Gaifax έγραψε:

> > How about a string i wonder? 
> > s = "νίκος" 
> > what_are these_bytes = s.encode('iso-8869-7').encode(utf-8')

> Ignoring the usual syntax error, this is just a variant of the code I 
> posted: "s.encode('iso-8869-7')" produces a bytes instance which
> *cannot* be "re-encoded" again in whatever encoding.

s = 'a'
s = s.encode('iso-8859-7').decode('utf-8')
print( s )

a (we got the original character back)
================================
s = 'α'
s = s.encode('iso-8859-7').decode('utf-8')
print( s )

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 0: unexpected end of data

Why this error? because 'a' ordinal value > 127 ?



More information about the Python-list mailing list