agrawal-d/cph

[Bug?] The Python `Received Output` will display Chinese as gibberish when without `Use Unicode UTF-8 for worldwide language support` in windows

Opened this issue · 0 comments

Extension Version: v6.1.0

VS Code Version: 1.89.0

Browser Version:

Operating System: Windows 11 x64

Python Version: 3.11.4

Description

Hi, CPH is really an excellent plugin, but it can't work well on my computer in some situations.

I have read the #338 and the problem seems to only happen in Python, I think it's better to open a new issue.

I don't know how to program in TypeScript, but I think we can provide a custom output encoding in the extension settings.

Here is some relevant information, thanks to the patient.

Use Unicode UTF-8 for worldwide language support

Control Panel > Clock and Region > Region > Administrative tab > Change system locale button > Beta:Use Unicode UTF-8 for worldwide language support.

Code

print("你好")

Test without UTF-8

without utf-8

Test with UTF-8

with utf-8

Test with custom TextIOWrapper and without UTF-8

from io import TextIOWrapper
import sys

sys.stdout = TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
print("你好")

with custom TextIOWrapper

Test with declear # coding:gbk and without utf-8

image