windows10环境下codeblock中文乱码问题
问题描述:
这几天刚在win10上安装了codeblock,在运行第一个程序时就遇到了乱码问题。
原因分析:
涉及编码的地方常见有:
-
源文件本身编码
-
编译器读取源文件编码
-
数据编码(数据库,IO文件等)
-
执行输出编码
解决方案:
对于windows系统来说,控制台的编码格式为windows-936(GBK),因此需要调整各级编码为windows-936(GBK)。
- 源文件本身编码
Setting->Editor->General Setting->Ecoding Setting.将相应选项改为WINDOWS 936
2.编译器读取源文件编码
打开Setting->Compiler->Global compiler setting->Compiler setting -> other compiler options;在相应位置填上-finput-charset=GBK
3.执行输出编码
打开Setting->Compiler->Global compiler setting->Compiler setting -> other compiler options;在相应位置填上-fexec-charset=GBK
进行完以上流程后,重新创建文件并编译运行即可。