1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <wchar.h> #include <stdio.h> #include <stdlib.h> #define CODEUNIT(c) (0xdfff & (signed char)(c)) wint_t btowc(int c) { if ((unsigned char)c < 128U) { return c; } if (MB_CUR_MAX == 1 && c != EOF) { return CODEUNIT(c); } return WEOF; }