I'm using Win10 & Scite with utf-8 enabled output window. The file is saved as UTF-8 with BOM
Script:
print('ダイスキ from python 3')
The script can be run on cmd prompt
without error. But when run on Scite
it will produce error:
Output:
>pythonw.exe -u "test.py"
Traceback (most recent call last):
File "test.py", line 12, in <module>
print('\u30c0\u30a4\u30b9\u30ad from python 3')
File "D:\BIN\Python37\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 1-2: character maps to <undefined>
>Exit code: 1
How to properly print ダイスキ to stdout using python3 with Scite?
Updates:
I've edited Scite Global Options file, to support utf-8.
code.page=65001
I've tested C, Lua, old Python 2.7, and it can print utf-8 strings (on Scite output window).
Seems to be Scite configuration error or a maybe Scite bug, because the Scite output terminal window works on Lua & C, but fail only on Python3.
Scite involves popen() / piping the STDOUT.
Python 3.7 need env variable "PYTHONIOENCODING" to be set manually. So you need to add environment variable "PYTHONIOENCODING" set to "utf_8"
Result: