How to solve "Chinese Garbled(中文乱码)" in UTF-8?
Answered
System:Win11 Chinese version
Clion:2023.1
Hello,can you help me how to solve "Chinese Garbled(中文乱码)"?
When I run directly, Chinese in console is garbled
But when I run in debug:
it shows correct:
By the way, i try to change the cpp encoding to GBK, it shows correct by run directly
but run in debug is garbled:
Here are my config:
Settings->File Encodings:
Global Encoding, Project Encoding , properties files: UTF-8
Settings->Toolchains:
default is VS
Settings->Cmake:
vmoptions:
-Dconsole.encoding=UTF-8
-Dfile.encoding=UTF-8
-Dfile.encoding=UTF-8
how to sovle it by UTF-8 and shows correct?
I am looking forward to your help, thank you very much.
Please sign in to leave a comment.
Hello!
Please go to
File | Settings | Advanced Setting
-Run/Debug
and uncheck theEmulate terminal in the output console
option, it should help.I uncheck the
Emulate terminal in the output console
option, it can't helpIt seems you faced https://youtrack.jetbrains.com/issue/CPP-28938. Feel free to comment or upvote the issue in order to get updates. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.
For now, as a workaround, you can use the "Run in external console" option in your run/debug configuration (
Run | Edit Configurations...
).Or you can try disabling
run.processes.with.pty
as suggested in this comment.I encountered the same problem in clion2023.1 under windows10, what is the reason?
1191432275 there is a bug in CLion, please take a look at my comment above.
This issue may due to the default encoding for different language in Windows. (For example, GBK is used for simplified Chinese version.) I check the "Use Unicode UTF-8 for worldwide language support" in Windows language settings and then the text is displayed correctly. (See: https://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8#answer-1435645)