How to make ncurses display UTF-8 chars correctly in C?

后端 未结 2 1687
無奈伤痛
無奈伤痛 2020-12-02 01:56

I have a program written in C using ncurses. It let user input and display it. It does not display correctly if user input utf8 chars.

I saved the chars user inputed

2条回答
  •  既然无缘
    2020-12-02 02:19

    You need to have called setlocale(LC_CTYPE, ""); (with a UTF-8 based locale configured) before initializing ncurses. You also need to make sure your ncurses is actually built with wide char support ("ncursesw") but on modern distros this is the default/only build.

提交回复
热议问题