I was in trouble because the Japanese output during debugging was garbled, so make a note of how to deal with it. It seems that the terminal used for output is not UTF-8.
VSCode Extensions:
TODO: Unsolved (seems to be listed in Issue)
Tasks should support specifying the output encoding · Issue #3550 · Microsoft/vscode
I also saw a comment that could be solved by sending the output of the task to the terminal. (Unverified)
Run build task fails · Issue #20152 · Microsoft/vscode
It was also possible to respond by adding the following settings
Change the standard output encoding
import sys
import io
sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
TODO list when encountering UnicodeDecodeError in Python3 --Qiita
It is assumed that launch.json has the following settings. (Generated by pressing the debug gear mark in the initial state)
launch.json
{
"name": "Integrated Terminal/Console",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config.python.pythonPath}",
"program": "${file}",
"cwd": "null",
"console": "integratedTerminal",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
},
In Debug, select ʻIntegrated Terminal / Console`. Execute it once, and execute the following on the displayed terminal.
UTF terminal-Fixed to 8
Terminal> chcp 65001
There should be no problem with the subsequent Japanese output. (The terminal will be reused, but if you close it, please try again)
Visual Studio Code --Visual Studio Code OUTPUT is garbled (42828) | teratail