Kudos for the great work. I have one problem with PTVS since I started using it: although the interactive prompt uses utf-8 encoding, the debugging terminal does not.
Since most of my scripts deal with CJK processing, I cannot use any of PTVS debugging features.
Steps to reproduce:
- Create a new utf-8 encoded python script (cjk.py)
- Add this line: "print(‘打印’)"
- Run the script in the interactive prompt: you see "打印"
- Open a command prompt (cmd.exe), type "chcp 65001", then "python cjk.py": you see "打印"
- Launch the PTVS debugger: a black console window (python.exe) opens and python crashes:
Traceback (most recent call last):
File "cjk.py", line 1, in <module>
File "C:\Python33\lib\encodings\cp850.py", line 19, in encode
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: character maps to <undefined>
Note that the problem is the same if you start python manually from a command line, but "chcp 65001" fixes it.
I've tried the following to fix the problem:
- Set the default console encoding in windows by adding chcp 65001 to the console autorun registrey setting. No effect.
- Override python's default encoding by setting the environment variable PYTHONIOENCODING=utf-8 . This effectively suppresses the error, but you see: "µëôÕì░".
I can see to solutions to this:
- Let users set the console encoding (as in Notepad++ NppExec plugin, for which setting the console encoding to utf-8 and forcing the encoding using PYTHONIOENCODING does work)
- Let users debug in the python interactive (that would also be great because it would prevent the annoying black window from flashing while you debug step by step).
Implementing both would be nice as well; at the moment I cannot find any workaround, which makes the debugging feature much less useful than it could be...
Thanks for the great work on PTVS.