现在想在Linux下显示中文
代码如下
#include <clocale>
#include <cwchar>
void optionVersion()
{
wchar_t wstr[] = L"简体中文版 by 大师♂罗莊";
wprintf(L"%ls",wstr);
exit(0);
}
报错converting to execution character set:无效或不完整的多字节字符或宽字符。
上网查没有找到解决方法。
自行研究发现,需要指定GCC或者G++ 的编码
比如我的源文件是gbk编码,那么这样加参数 -finput-charset='gbk'
输出中文,赏心悦目:
luozhuang@luozhuang-virtual-machine ~/NetBeansProjects/Onscripter-20121116cnlinux/dist/Release/GNU-Linux-x86 $ ./onscripter-20121116cnlinux
<init> : Avifile RELEASE-0.7.48-120520-08:05-../src/configure
<init> : Available CPU flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss nx rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc
<init> : 1995.53 MHz Intel(R) Core(TM) i7-2630QM CPU @ 2.00GHz processor detected
ONScripter version 20120701 简体中文版 by 大师罗莊(2.96)
can't open any of 0.txt, 00.txt, nscript.dat and nscript.___
luozhuang@luozhuang-virtual-machine ~/NetBeansProjects/Onscripter-20121116cnlinux/dist/Release/GNU-Linux-x86 $