Display wchar_t using ncurses

前端 未结 1 1717
悲哀的现实
悲哀的现实 2020-12-06 08:49

i\'m currently working on a C++ project in which I need to display some extended characters (wchar_t).

The main problem is that, even if it works fine in C (using

相关标签:
1条回答
  • 2020-12-06 09:19

    You need to setlocale(LC_ALL, "") before doing initscr().

    A working example:

    #include <ncursesw/ncurses.h>
    #include <locale.h>
    #include <wchar.h>
    
    int main() {  
        setlocale(LC_ALL, "");
        initscr();
        wchar_t wstr[] = { 9474, L'\0' };
        mvaddwstr(0, 0, wstr);
        refresh();
        getch();
        endwin();
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题