When I created Project C in Clion 2019.1.4, and ran the following program, the Japanese part of the execution result was translated into characters, which is troubling me.
#include<stdio.h>
int main() {
printf("Hello World");
return 0;
}
Run Results
C:\Users\USERNAME\CLionProjects\untitled\cmake-build-debug\untitled.exe
上 up and down
Process finished with exit code 0
The source file is encoded as UTF-8.
I tried to change the encoding of the source file to ShiftJIS and it was fixed, but if possible, I would like to keep the encoding of the source file as UTF-8 and improve garbled characters.
Other things I've tried are as follows:
The operating system is Windows 10 Home Version 1803 Build 17134.829.
Probably because the source file is UTF-8 and the console is encoded as Shift JIS, I can't confirm it and I don't know how to deal with it.
How can I fix garbled characters?
Additional
Debugging instead of running showed no garbled characters.
Is the encoding different between the running console and the debugging console?
If possible, I would like to avoid garbled characters on the execution console.
The input and output have different character sets and must be explicitly specified.
Try adding the line below to MakeLists.txt.
set(CMAKE_CXX_FLAGS"${CMAKE_CXX_FLAGS}/execution-charset:SHIFT_JIS/source-charset:UTF-8")
© 2024 OneMinuteCode. All rights reserved.