pkgsrc-Users archive

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

ncursesw: Problems with displaying wide chars



Hello,

I run NetBSD CURRENT amd64 with pkgsrc, both two months old (I'll reinstall next days).

I notice problems with displaying wide chars with ncursesw.

Attached there is an archive with a short C file which prints a multibyte string ("äöüß") one time with printw(), then with add_wchstr().

printw() prints the umlauts "äüö" but doesn't print "ß".  add_wchstr() prints nothing useful.  Compiling the same with

make -f ncurses

on any other UNIX works fine.

When I compile the same with curses:

make -f curses

add_wchstr() always works correct.  printw() is correct in xterm (TERM=xterm) but prints the raw ASCII characters in tmux(1) (TERM=screen).  This may be a curses issue, but since I always use add_wchstr() I have no problem with that.

I set the locale with

export LC_ALL=en_US.UTF-8

and the the locale is

$ locale
LANG=""
LC_CTYPE="en_US.UTF-8"
LC_COLLATE="C"
LC_TIME="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

The contents of the archive is (must be UTF-8 encoded):

$ cat main.c                                                                                                                                                                                   
#define _XOPEN_SOURCE_EXTENDED
#include <locale.h>
#include <stdlib.h>
#ifdef NCURSESW
# include <ncursesw/curses.h>
#else
# include <curses.h>
#endif

int
main()
{
        static wchar_t ws[2];
        wchar_t wcs[100];
        cchar_t ccs[100];
        wchar_t *wcp;
        cchar_t *ccp;
        char *mbs = "äöüß";

        setlocale(LC_ALL, "");
        initscr();

        printw("%s\n", mbs);

        mbstowcs(wcs, mbs, sizeof(wcs)/sizeof(*wcs));

        wcp = wcs;
        ccp = ccs;

        do {
                *ws = *wcp++;
                setcchar(ccp++, ws, 0, 0, NULL);
        } while (*ws);

        add_wchnstr(ccs, -1);

        refresh();
        getch();
        endwin();
        return 0;
}

$ cat ncurses
INCDIR=         -I/usr/pkg/include
LIBDIR=         -L/usr/pkg/lib
RPATH=          -Wl,-rpath,/usr/pkg/lib
LDADD=          -lncursesw

main: main.o
        $(CC) $(RPATH) $(LIBDIR) -fsanitize=address main.o -o $@ $(LDADD)

clean:
        rm -f main.o main

.c.o:
        $(CC) -c $(CFLAGS) -DNCURSESW $(INCDIR) -fsanitize=address $<

$ cat curses                                                                                                                                                                                   
LDFLAGS=-lcurses
CFLAGS=-g #-fsanitize=address

all: main

clean:
        rm -f main

Attachment: test.tgz
Description: Binary data



Home | Main Index | Thread Index | Old Index