現在想在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 detectedONScripter 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 $