ruby / curses

Ruby binding for curses, ncurses, and PDCurses. Formerly part of the ruby standard library.
Other
297 stars 34 forks source link

.box() doesn't work with UTF-8 #38

Closed soanvig closed 5 years ago

soanvig commented 7 years ago

Hi.

The .box() method does not work with UTF-8 characters.

window.box('│', '─') leads to displaying â character (it is grey rectangle in my terminal).

Where these dashes are box-drawing characters copied directly into the code (with unicode transcription it doesn't work either).

What works however is UTF-8, but with .addstr() method.

Curses 1.2.4 Ruby 2.4 Fedora 25

shugo commented 5 years ago

The following C program also doesn't work with ncurses.

#include <ncurses.h>

int main()
{
    initscr();

    WINDOW *win = newwin(9, 40, 5, 20);
    mvwaddstr(win, 4, 15, "Hit ay key");
    box(win, 0x2502, 0x2500);
    touchwin(win);
    wrefresh(win);

    getchar();

    endwin();
    return 0;
}

Do you have any version of curses whose box() supports Unicode?

sh7d commented 5 years ago

This is not problem of ruby curses bindings, using chars like that is more complicated in ncurses in general Try something like that:

win.attron(Curses::A_ALTCHARSET)
win.box(120, 113)
win.attroff(Curses::A_ALTCHARSET)
win.refresh

Keyword: Ncurses extended characters :) There should be constants from original ncurses library embedded into ruby curses bindings, but currently there arent any :(

shugo commented 5 years ago

@sh7d Thanks for your comment.

I close this issue because it's not an issue of Ruby bindings.