1. Modify the source file storage Encoding
Settings-> Editor-> gernal settings encoding group box on the right
Use encoding when opening files: indicates the format used to open the file. This format is also used when the file is saved for the first time.
As default encoding: indicates that the file is saved by default and the encoding format is enabled.
Note: It is valid only when the file is set and then saved. If you have saved the file, no matter how you modify this setting, it will not change the format of your file. Your file remains in the format when it is saved for the first time.
Therefore, if the file cannot take effect, you must set the format and recreate the file.
2. Modify the encoding format used by the compiler to interpret the source file and generate the execution file.
Settings-> compiler and debugger settings select the corresponding GCC compiler
Add the following content to other options:
-Finput-charset = charset
-Fexec-charset = charset
The first parameter indicates the encoding format of the input file during compilation, and the second parameter indicates the encoding format used for executing the generated execution file.
If these parameters do not match the actual conditions, garbled characters are generated. As long as they match, they will not be garbled.
Since my source file format is Windows-936, but here it is set to UTF-8, so compilation certainly reports an error!
You only need to modify it to-finput-charset = Windows-936 or GBK, and the compilation is successful.
If you do not set fexec-charset default will think that the execution environment is UTF-8, and windows is not, so Linux is no problem, because Linux is the UTF-8, But windows will inevitably appear garbled.
Therefore, set it to GBK.
Original article address:Http://blog.csdn.net/softman11/article/details/6121538
I have simply sorted it out ~