bug-ncurses
[Top][All Lists]
Advanced

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

Portable way to accept unicode keyboard input


From: Sam Varshavchik
Subject: Portable way to accept unicode keyboard input
Date: Fri, 25 Feb 2011 06:51:42 -0500

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.

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?

Basically -- what's the most portable approach to reading unicode values from the keyboard?

Attachment: pgp6GCmrd9Ofl.pgp
Description: PGP signature


reply via email to

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