简体   繁体   中英

Problem with printing extended ascii using ncurses

I have got problem with printing extended ascii in terminal using wprintw function. This program prints letters instead squares. I was trying to change my locales but without effect. What should I change in my system to print it correctly?

#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
#include <unistd.h>
#include <locale.h>
#include <wchar.h>

int main(void)
{
    setlocale(LC_ALL, "");
    initscr();
    WINDOW *game_window;
    game_window=newwin(40,40,1,1);
    wrefresh(game_window);

    while (TRUE) {
        wclear(game_window);
        wprintw(game_window, "██████████████████████");
        wrefresh(game_window);
        sleep(3);
        break;
    }
    endwin();
    return 0;
}

I am working On Debian Jessie 10 and these are my locale:

LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Ok, I find the solution, when compiling the program you should use this command:

gcc main.c -o main -lncursesw

Instead this:

gcc main.c -o main -lncurses

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM