jeaye / ncurses-rs

A low-level ncurses wrapper for Rust
Other
685 stars 99 forks source link

garbled Chinese characters and setlocale doesn't work #212

Open SmileXie opened 2 years ago

SmileXie commented 2 years ago

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, "")