Codeblocks Chinese garbled Solution

Source: Internet
Author: User

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 ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.