下面的代码无法打印宽字符:
#include <ncurses.h>
using namespace std;
int main(void){
initscr();
printw("█");
getch();
endwin();
}
尽管所有库都已正确安装,但此代码似乎在某些计算机上有效,而在其他计算机上无效。 (终端可以显示扩展字符!)
我编译这个使用:
g++ -std=c++14 widechartest.cpp -o widechar -lncursesw
谁能告诉我问题出在哪里? 谢谢 8)
最佳答案
您没有初始化语言环境。 manual page指出这一点:
The library uses the locale which the calling program has initialized. That is normally done with
setlocale
:
setlocale(LC_ALL, "");
If the locale is not initialized, the library assumes that characters are printable as in ISO-8859-1, to work with certain legacy programs. You should initialize the locale and not rely on specific details of the library when the locale has not been setup.
关于c++ - 使用 Ncurses (C++) 时不打印宽字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48466519/