Netbeans C++ 不打印 UTF-8 字符
Netbeans C++ not printing UTF-8 characters
这是非常简单的 C++ 代码:
char a00 = 'Z';
char a01 = '\u0444';
char a02[5] = {'H','e','l','l','o'};
char a03[] = {'W','o','r','l','d','[=10=]','Z','Z'};
cout << "Simple char: " << a00
<< "\nUTF-8 char: " << a01
<< "\nFull char array: " << a02
<< "\n2nd in char array: " << a02[1]
<< "\nWith null character: " << a03 << endl;
我的问题是当 Netbeans 8.1 试图显示此类程序的输出时,它不会创建 UTF-8 字符。
字符应如下所示:ф(参见:link)
相反,我得到以下输出:
我尝试在 etc
文件夹内的 netbeans.conf
文件中将 -J-Dfile.encoding=UTF-8
添加到 netbeans_default-options
。没有区别。
UTF-8
是一种 多字节 字符编码,这意味着大多数字符占用几个字节。所以单个 char
不足以容纳大多数 UTF-8
个字符。
您可以将它们存储在这样的字符串中:
std::string s = "\u0444";
这是非常简单的 C++ 代码:
char a00 = 'Z';
char a01 = '\u0444';
char a02[5] = {'H','e','l','l','o'};
char a03[] = {'W','o','r','l','d','[=10=]','Z','Z'};
cout << "Simple char: " << a00
<< "\nUTF-8 char: " << a01
<< "\nFull char array: " << a02
<< "\n2nd in char array: " << a02[1]
<< "\nWith null character: " << a03 << endl;
我的问题是当 Netbeans 8.1 试图显示此类程序的输出时,它不会创建 UTF-8 字符。
字符应如下所示:ф(参见:link)
相反,我得到以下输出:
我尝试在 etc
文件夹内的 netbeans.conf
文件中将 -J-Dfile.encoding=UTF-8
添加到 netbeans_default-options
。没有区别。
UTF-8
是一种 多字节 字符编码,这意味着大多数字符占用几个字节。所以单个 char
不足以容纳大多数 UTF-8
个字符。
您可以将它们存储在这样的字符串中:
std::string s = "\u0444";