level 11
gameloftyou
楼主
举两种方案(针对中文操作系统,即本地编码为GBK):
一:
如果源代码编码为utf-8,比如main.cpp
控制台下执行:g++ -fexec-charset=GBK main.cpp
(注,main.cpp和生成的a.exe均在当前目录下)
二:
如果源代码编码为GBK,比如main.cpp
控制台下执行:g++ -finput-charset=GBK -fexec-charset=GBK main.cpp
(注,main.cpp和生成的a.exe均在当前目录下)
如果是IDE,只需将编码和相应的编译选项设置下就行了
其实飞哥昨天就说了,不过我脑残+手残一直没调试成功- -|||
测试代码:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
setlocale(LC_ALL,"chs");
wchar_t text[] = L"This is 中文。▆▇██■▓回";
wcout<<text<<endl;
cout<<"HelloWorld中文!"<<endl;
system("pause");
return 0;
}
2012年07月20日 10点07分
1
一:
如果源代码编码为utf-8,比如main.cpp
控制台下执行:g++ -fexec-charset=GBK main.cpp
(注,main.cpp和生成的a.exe均在当前目录下)
二:
如果源代码编码为GBK,比如main.cpp
控制台下执行:g++ -finput-charset=GBK -fexec-charset=GBK main.cpp
(注,main.cpp和生成的a.exe均在当前目录下)
如果是IDE,只需将编码和相应的编译选项设置下就行了
其实飞哥昨天就说了,不过我脑残+手残一直没调试成功- -|||
测试代码:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
setlocale(LC_ALL,"chs");
wchar_t text[] = L"This is 中文。▆▇██■▓回";
wcout<<text<<endl;
cout<<"HelloWorld中文!"<<endl;
system("pause");
return 0;
}
