Print braille fonts in ncurses

I tried typing braille characters in ncurses.

This is my code:

#include <ncurses.h>

char *str = 
    " ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏\n"
    "⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟\n"
    "⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯\n"
    "⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿\n";


int main(int argc, const char *argv[]) {
    initscr();
    printw("%s", str);
    getch();
    printf("%s", curses_version());
    endwin();
    printf("%s", str);
    return 0;
}

Conclusion:

 ?~A?~B?~C?~D?~E?~F?~G?~H?~I?~J?~K?~L?~M?~N?~O
?~P?~Q?~R?~S?~T?~U?~V?~W?~X?~Y?~Z?~[?~\?~]?~^?~_
⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯
⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿

How to correctly display all characters?

Update: I also tried printf, which seems to work, addstrproduces the same output as printw.

If I change the locale with setlocale(LC_ALL, "");, I get the output:

  A B C D E F G H I J K L M N O
 P Q R S T U V W X Y Z [ \ ] ^ _
⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯
⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿
+4
source share
1 answer

In some experiments, I found that it was probably wrong:

  • C. ASCII. stdio, , . ncurses , , , ( ) .. :

    #include <curses.h>
    #include <locale.h>
    
    int main(int argc, char *argv[])
    {
        // initialize locale to system default:
        setlocale(LC_ALL, "");
    
        // now init and use curses ...
    
  • , libncurses unicode. ncursesw ncurses, .

+2

Source: https://habr.com/ru/post/1683807/


All Articles