我最近安裝了新的Windows 10構建14393,我想使用新的Linux子系統。所以我決定學習ncurses,並且我找不到如何從getch
那裏獲得口音像è
這樣的字符的UTF-8代碼。 因此,這裏是我的代碼:如何使用獲得UTF-8口音與ncurses
#include <iostream>
#include <string>
#include <curses.h>
using namespace std;
int main(int argc, char **argv)
{
char ch;
setlocale(LC_ALL, "fr_FR.UTF-8");
initscr();
cbreak();
noecho();
printw("èèè\n"); // i can print accents
ch = getch(); // if i press è it gives me 2 characters
printw("%d", ch);
ch = getch();
printw("%d", ch);
getch(); // wait for a key to exit
endwin();
return 0;
}
例如,如果我按è
它給了我2個字符代碼是-61
和-88
,所以,我怎麼能有從UTF-8
表是232
其代碼? 我用ncursesw這裏是我g++
命令編譯:
g++ file.cxx -o file -lncursesw
我的語言環境配置爲fr_FR.UTF-8。 感謝您的任何答案。
[long story](http://www.unicode.org/reports/tr17/),簡而言之,utf8將不同的代碼點編碼爲1個或多個字節的序列。 –