bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help... trouble writing out wide characters


From: Bryan Christ
Subject: Re: Need help... trouble writing out wide characters
Date: Fri, 21 Dec 2018 13:05:48 -0600

Well it turns out that if you setlocale("UTF8") it will work to a point :/  Setting it to en_US.UTF-8 fixed all the problems.  Is there a canonical way of setting this?  It occurs to me to read the LANG evn variable but is that reliable?

On Thu, Dec 20, 2018 at 8:00 PM Thomas Dickey <address@hidden> wrote:
On Thu, Dec 20, 2018 at 07:35:09PM -0600, Bryan Christ wrote:
> I've ported all of my terminal emulator code so that it writes the output
> window using mvadd_wch().  Everything works fine including cchar_t types
> created by NCURSES_WACS(x).  The problem I'm running into occurs when I use
> setcchar() to construct a cchar_t.  As long as the value I stuff into
> wch[0] is basically low ascii (or ACS), it displays just fine.  Whenever
> the value is actually utf8 encoded, I typically see a glyph in the window
> that looks like a question mark inside a solid circle.  Skipping over lots
> of irrelevant stuff, my debug code is basically:
>
> wchar_t      wch[] = { 0xE29480, 0x0000 };

That's asking for Unicode U+E29480

https://www.fileformat.info/info/unicode/char/2500/index.htm

hints that you're thinking of UTF-8.

You can pass the UTF-8 bytes (assuming that your locale encoding _is_ UTF-8)
via addch in ncurses:

https://invisible-island.net/ncurses/man/curs_addch.3x.html#h3-Character-Set

If you want to make it portable to "any" X/Open Curses, you'd have to
convert the 3 bytes into a wide-character, e.g., using mbrtowc or mbsrtowcs,
and pass _that_ to add_wch

Interesting, SVr4 curses (reading the Illumos source-code) allowed
multibyte characters via addch.  But X/Open says

        addch, mvaddch, mvwaddch, waddch - add a single-byte character and
        rendition to a window and advance the cursor

> setcchar(&my_cchar, wch, 0, 0, NULL);
> mvadd_wch(window, y, x,  &my_cchar);
>
> Now that's above is the debug code.  If I don't hard-code what's in wch and
> let the CSI interpreter do it's thing, what I see is a bunch of q's, x's,
> w's, etc... that you would normally expect to see in ACS mode when it's not
> being properly handled.

--
Thomas E. Dickey <address@hidden>
https://invisible-island.net
ftp://ftp.invisible-island.net


--
Bryan
<><

reply via email to

[Prev in Thread] Current Thread [Next in Thread]