[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
UTF-8 output via "echo_wchar" resulting in errno=1 on Mac OS X
From: |
Christoph Ender |
Subject: |
UTF-8 output via "echo_wchar" resulting in errno=1 on Mac OS X |
Date: |
Mon, 18 Apr 2011 23:19:55 +0200 |
Hello all,
I've noticed that output of non-ASCII chars using a self-compiled ncurses 5.9
(the only
compile-option being --enable-widec) or the MacPorts binary package of ncurses,
also in
version 5.9, results in an errno=1. I've attached a very simple, non-nice code
snippet which
outputs a simple 'a' and an up-down-arrow (0x2195, other non-ASCII chars like
the
umlaut-a: "ä" also produce the effect):
---------------------------------------------------------------------------------------
#define _XOPEN_SOURCE_EXTENDED 1
#include <ncursesw/ncurses.h>
#include <errno.h>
#include <wchar.h>
#include <stdio.h>
#include <locale.h>
static attr_t ncursesw_no_attrs = 0;
int main(int argv, char *argc[])
{
wchar_t ncursesw_setcchar_init_string[2];
cchar_t wcval;
int e1, e2;
ncursesw_setcchar_init_string[1] = 0;
setlocale(LC_ALL, "");
initscr();
cbreak();
noecho();
ncursesw_setcchar_init_string[0] = 'a';
setcchar(
&wcval,
ncursesw_setcchar_init_string,
ncursesw_no_attrs,
0,
NULL);
echo_wchar(&wcval);
printw(", errno: %d.\n", errno);
ncursesw_setcchar_init_string[0] = 0x2195;
setcchar(
&wcval,
ncursesw_setcchar_init_string,
ncursesw_no_attrs,
0,
NULL);
e1 = errno;
printw("errno: %d.\n", e1);
e1 = errno;
echo_wchar(&wcval);
e2 = errno;
printw("e1: %d, e2: %d\n", e1, e2);
refresh();
getch();
endwin();
return 0;
}
---------------------------------------------------------------------------------------
This will result in the following output:
a, errno: 0.
errno: 0.
↕e1: 0, e2: 1
The non-ASCII chars themselves are displayed without any problems, the only
issue being that errno is set for some unknown reason. Using the ncurses
distributed with Mac OS X instead of a self-compiled or the MacPorts-version
will
work correctly (in which case e2 has the expected value of 0). Trying the code
on
an Intel machine running Debian Squeeze will also work without problems, both
using selfcompiled and bundled ncurses.
I have no idea whether this is due to a bug, a misconfiguration of ncurses or
some error in the code. I'm aware that Mac OS X is not a supported system, but
does anyone by chance have an idea what might be the cause?
Thanks in advance,
Christoph.
- UTF-8 output via "echo_wchar" resulting in errno=1 on Mac OS X,
Christoph Ender <=