Changing filenames from Greeklish => Greek (subprocess complain)

Heiko Wundram modelnine at modelnine.org
Thu Jun 6 04:50:55 EDT 2013


Am 05.06.2013 18:44, schrieb MRAB:
>  From the previous posts I guessed that the filename might be encoded
> using ISO-8859-7:
>
>  >>> s = b"\305\365\367\336\ \364\357\365\ \311\347\363\357\375.mp3"
>  >>> s.decode("iso-8859-7")
> 'Ευχή\\ του\\ Ιησού.mp3'
>
> Yes, that looks the same.

Most probably, his terminal is set to ISO-8859-7, so that when he issues 
the rename command on the command-line of his shell session, the "mv" 
command gets a stream of bytes as the new file name which happens to be 
the ISO-8859-7 encoding of the file name he'd like the file to have. 
This is what's stored on disk.

So, his biggest problem isn't that the operating system is encoding 
agnostic wrt. filenames (i.e., treats them as a stream of bytes), but 
rather that he's using an ISO-7 terminal window when having set up UTF-8 
as his operating system locale and expects filenames to be encoded in 
UTF-8 when he's not passing in UTF-8 byte streams from his client 
computer at all.

-- 
--- Heiko.



More information about the Python-list mailing list