Executing the following python program
test.py:
# -*- coding: utf-8 -*-
print "Hühnchen"
hexdump:
00000000 23 20 2d 2a 2d 20 63 6f 64 69 6e 67 3a 20 75 74 |# -*- coding: ut|
00000010 66 2d 38 20 2d 2a 2d 20 0a 0a 70 72 69 6e 74 20 |f-8 -*- ..print |
00000020 22 48 c3 bc 68 6e 63 68 65 6e 22 0a |"H..hnchen".|
from the command prompt in Windows 7 with code page 65001 and the Lucida Console font causes an IOError
:
$ python test.py
HühnchenTraceback (most recent call last):
File "test.py", line 3, in <module>
print "Hühnchen"
IOError: [Errno 2] No such file or directory
To exclude any side effects of my Windows installation I reproduced the problem in a fresh virtual machine with the following steps:
- Install Windows 7 Ultimate SP1 Build 7601 (SHA1 of the ISO:
36ae90defbad9d9539e649b193ae573b77a71c83
) in a virtual machine - Install python 2.7.13 64-bit
- Open
cmd.exe
- Set the font to Lucida Console
- Change the code page to 65001 to support UTF-8
- Execute the above script (make sure that the file encoding is UTF-8)
What is happening here?