jeaye/ncurses-rs

garbled Chinese characters and setlocale doesn't work

Closed this issue · 1 comments

I am trying to print Chinese character in a ncurses screen

    log::debug!("row str {}", row_str);
    ncurses::addstr(&row_str);

variable row_str is displayed well in as a parameter of log::debug , but get garbled by using ncurses::addstr.

i've tried to fix by the following 3 methods, but no one works.

    // method 1
    gettextrs::setlocale(gettextrs::LocaleCategory::LcAll, "");
    // method 2
    use libc::setlocale;
    unsafe {
        setlocale(0, "".as_bytes().as_ptr() as *const i8);
    }
    //method 3
    ncurses::setlocale(ncurses::constants::LcCategory::all, "")

same as : #212