Changing filenames from Greeklish => Greek (subprocess complain)
Lele Gaifax
lele at metapensiero.it
Sun Jun 9 05:20:58 EDT 2013
Νικόλαος Κούρας <nikos.gr33k at gmail.com> writes:
> Τη Κυριακή, 9 Ιουνίου 2013 11:55:43 π.μ. UTC+3, ο χρήστης Lele Gaifax έγραψε:
>> Uhm, no: "encode" transforms a Unicode string into an array of bytes,
>> "decode" does the opposite transformation. You cannot do the former on
>> an "arbitrary" array of bytes:
>>
>> >>> s = "νίκος"
>> >>> utf8_bytes = s.encode('utf-8')
>> >>> greek_bytes = utf8_bytes.encode('iso-8869-7')
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> AttributeError: 'bytes' object has no attribute 'encode'
>
> So something encoded into bytes cannot be re-encoded to some other bytes.
>
> 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.
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it | -- Fortunato Depero, 1929.
More information about the Python-list
mailing list