[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Portable way to accept unicode keyboard input
From: |
Thomas Dickey |
Subject: |
Re: Portable way to accept unicode keyboard input |
Date: |
Sat, 26 Feb 2011 09:51:46 -0500 (EST) |
On Fri, 25 Feb 2011, Sam Varshavchik wrote:
On Linux, and probably most modern platforms, when I look at what's in
wchar_t, I see unicode values. Or, more precisely, UCS-4 in the native byte
order. However, elsewhere I've been led to believe that this is really
implementation defined; an implementation might put something else for a
wchar_t.
I see occasional comments, which suggest that it's not the case for
Solaris, for instance.
So I'm reading my wchar_ts from get_wch(), and my application uses unicode to
throw text strings around. If wchar_t is not guaranteed to be UCS-4, then I'm
trying to figure out what's the most portable way to convert keyboard input
to unicode.
The first thing that came to mind was use wcrtomb() to convert wchar_ts to a
multibyte sequence, then stack iconv() on top of that, and end up with UCS-4
values that way. But if I need to do that, shouldn't I just be able to read
the same multibyte sequence with getch(), instead?
That's essentially what get_wch() is doing.
--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net