bug-ncurses
[Top][All Lists]
Advanced

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

I've made a simple program, showing UTF-8 lower but not uppercase workin


From: amores perros
Subject: I've made a simple program, showing UTF-8 lower but not uppercase working
Date: Fri, 23 Sep 2005 21:04:22 +0000

Since my last post here, I've proceeded to isolate a test program
successfully printing a UTF-8 string out via printf, but then
invoking ncurses and observing mixed results -- the lowercase
letters are ok, but the upperones are apparently trashed (I see
open boxes, and more characters than I should).

I'm still testing on ncurses5.4 from debian linux stable.

I'll enclose the source of my test program below.

I was unable to test using cchar_t and widechar variants
of the API, which I gather should exist on some versions,
because they were absent from /usr/include/ncurses.h
(where I expected to find them).

I'm not clear whether UTF-8 is supposed to be supported
on ncurses 5.4. Judging by some remarks about it here
 http://invisible-island.net/ncurses/announce.html
I deduce (but am not positive)  that it should be supported.

Notes:
I compile the program like so
gcc ct.c -lncurses

I will also enclose an output from the program -- but it doesn't
show the ncurses display, which is where the problem is.
What I see on the screen from ncurses is as follows
(all on one line near the middle of the screen, but here
I describe each character on a separate line):

** BEGIN

left square bracket
lowercase a with acute
lowercase n with tilde
lowercase i
hollow box
tilde
uppercase a
hollow box
tilde
uppercase Q
lowercase i
right square bracket
blinking cursor

** END

** BEGIN ct.c source **

#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>
#include <locale.h>

int main()
{
        WINDOW * win = 0;
        char str[60] = "[\xC3\xA1\xC3\xB1i\xC3\x81\xC3\x91i]";
        wchar_t wstr[60];
        unsigned len = strlen(str);
        /* u00E1, $C3$A1, LATIN SMALL LETTER A WITH ACUTE */
        /* u00F1, $C3$B1, LATIN SMALL LETTER A WITH ACUTE */
        /* lower case letter i */
        /* u00C1, $C3$81, LATIN CAPITAL LETTER A WITH ACUTE */
        /* u00D1, $C3$91, LATIN CAPITAL LETTER N WITH TILDE */
        /* lower case letter i */
        int i=0;
        wstr[i++] = '[';
        wstr[i++] = 0xE1; wstr[i++] = 0xF1; wstr[i++] = 'i';
        wstr[i++] = 0xC1; wstr[i++] = 0xD1; wstr[i++] = 'i';
        wstr[i++] = ']'; wstr[i++] = 0;

        setlocale(LC_ALL, "en_US.UTF-8");
        printf("locale: %s\n", setlocale(LC_ALL, NULL));

        printf("test UTF-8 string: <%s>\n", str);
        printf("test wstring: <%ls>\n", wstr);

        win = initscr();

        if (!win) return 1;
        noecho();
        keypad(win, 1);

        mvwaddstr(win, 10, 10, str);

/*      mvwcaddstr(win, 10, 10, wstr);*/

        touchwin(win);
        wrefresh(win);

        getch();

        endwin();
}

** END

** BEGIN output capture (not including ncurses display text)

locale: en_US.UTF-8
test UTF-8 string: <[áñiAÑi]>
test wstring: <[áñiAÑi]>

** END output capture

Note:
I captured that output into a file, which was naturally
in UTF-8 (as my gnome-terminal was in UTF-8), and
I ftp'd it to a windows machine, then used iconv to
convert it from UTF-8 to latin1, in the hopes that this
email I'm sending will be in latin1).


Cordially,

Perry






reply via email to

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