Leonardo Boiko | 24 Feb 01:40

utf-8 strings in ncursesw with c-wrapper

Hi.  I'm trying to use ncursesw with c-wrapper, with a preamble like:

    (use c-wrapper)
    (c-load "ncursesw/ncurses.h" :libs "-lncursesw")

And this works:

    (initscr)
    (mvaddstr 0 0 "Hello, world!")
    (refresh)
    (endwin)

But this results in mojibake:

    (initscr)
    (mvaddstr 0 0 "こんにちは、世界!")
    (refresh)
    (endwin)

The C version works if I call setlocale before starting:

    #include <ncursesw/ncurses.h>
    #include <locale.h>

    int main(void)
    {
            setlocale(LC_CTYPE, "en_US.UTF-8");
            initscr();
            mvaddstr(0, 0, "こんにちは世界!");
            refresh();
(Continue reading)

Leonardo Boiko | 24 Feb 01:46

Re: utf-8 strings in ncursesw with c-wrapper

Nevermind, I just found I must call sys-setlocale _before_ initscr.
Because I was using a convenience macro to call initscr, I failed to
notice I was calling stuff in a different order than C.  Sorry for the
bother :)

--

-- 
Leonardo Boiko
http://namakajiri.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Gmane