On Mon, Apr 15, 2013, at 15:36, Thorsten Glaser wrote: > Actually, wint_t is the standard type to use for this. One > could also use wchar_t but that may be an unsigned short on > some systems, or a signed or unsigned int.
Those systems aren't using wchar_t *or* wint_t for unicode, though. The main reason for wint_t's existence is that wchar_t isn't guaranteed to be able to represent a WEOF value distinct from all valid character values. wchar_t can be used just fine for any actual character, but if the system doesn't use unicode as its wchar type, it could (for example) be a signed 16-bit int to wchar_t's unsigned 8-bit. You can use #if __STDC_ISO_10646__ to test whether the implementation uses unicode for wchar_t (most modern systems do, though some may not define this constant) - if so, then wchar_t is, naturally, guaranteed to be able to represent at least the range 0 to 0x10FFFF, and wint_t that plus WEOF (usually -1). They're usually both 32-bit signed ints. MS Windows uses an unsigned short for both types due to various historical reasons.