Visual Studio Code can't encode cyrillic characters in output

6.9k Views Asked by At

Output in Visual Studio Code can't decode Cyrillic characters:

Visual Studio Code can't decode Cyrillic characters

The same code works fine in PyCharm:

The same code works fine in PyCharm

How do I quickly fix this issue? There must be some simple way.

Auto Guess Encoding in Settings doesn't work since it's for files, not the output.

Edit: the problem was the Code Runner extension in VSCode. Disabling it or running script in terminal does the job.

2

There are 2 best solutions below

0
ill On

You can configure 'Code Runner' plugin to run your code in the integrated terminal.

Try it:

  1. Open VSC Settings: Ctrl + ,
  2. Search: code runner run in terminal
  3. Click on checkbox.

Now your application with Cyrillic symbols run in Integred Terminal without encoding problems.

1
Alexander Dark On

The problem lies in the Code Runner encoding itself, since the text is displayed correctly in the terminal.

You can add into settings.json :

"code-runner.executorMap": {"python": "set PYTHONIOENCODING=utf8 && py -u"},