GCC converting to execution character set:無效或不完整的多位元組字元或寬字元

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.