[Tutor] Unicode? UTF-8? UTF-16? WTF-8? ;)
Steven D'Aprano
steve at pearwood.info
Wed Sep 5 17:25:51 CEST 2012
On 06/09/12 00:51, Ray Jones wrote:
> subprocess.call(['dolphin', '/my_home/testdir/\u044c\u043e\u0432'])
>
> Dolphin's error message: 'The file or folder
> /my_home/testdir/\u044c\u043e\u0432 does not exist'
That's because you're telling Dolphin to look for a file literally called:
BACKSLASH u ZERO FOUR FOUR c BACKSLASH ...
Either use the actual unicode string, which you can write like either of
these:
u'/my_home/testdir/ьов'
u'/my_home/testdir/\u044c\u043e\u0432'
(note the leading u' delimiter, not just ')
or try using the raw bytes instead:
'/my_home/testdir/\xd1\x8c\xd0\xbe\xd0\xb2'
(assuming Dolphin is using UTF-8) and hope Dolphin can decode them
correctly. (It better.)
--
Steven
More information about the Tutor
mailing list