【发布时间】:2014-05-03 22:34:18
【问题描述】:
我正在尝试制作简单的多语言 Windows 控制台应用程序,仅用于教育目的。我在 WxDev-C++/minGW 4.6.1 中使用 c++ lahguage,我知道这种问题被问了百万次。我可能搜索了整个互联网,也可能查看了所有论坛,但没有任何帮助。
这是示例工作代码:
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
/* English version of Hello world */
wchar_t EN_helloWorld[] = L"Hello world!";
wcout << EN_helloWorld << endl;
cout << "\nPress the enter key to continue...";
cin.get();
return 0;
}
在我尝试放入一些非常宽泛的字符(例如“Ahoj světe!”)之前,它非常有效。问题在于“ě”,即十六进制 unicode 中的“011B”。编译器给我这个错误:“非法字节序列。”
不工作的代码:
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
/* Czech version of Hello world */
wchar_t CS_helloWorld[] = L"Ahoj světe!"; /* error: Illegal byte sequence */
wcout << CS_helloWorld << endl;
cout << "\nPress the enter key to continue...";
cin.get();
return 0;
}
我听说过诸如#define UNICODE/_UNICODE、-municode 或为旧版 minGW 下载包装器之类的事情。我试过了,但它不起作用。可能是我不知道如何正确使用它们。无论如何,我需要一些帮助。在 Visual Studio 中,这很简单。
非常感谢您的回复。
【问题讨论】:
标签: c++ windows unicode console mingw