diff options
Diffstat (limited to 'lib/libc/wchar/wctob.c')
| -rw-r--r-- | lib/libc/wchar/wctob.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libc/wchar/wctob.c b/lib/libc/wchar/wctob.c new file mode 100644 index 00000000..702e3f75 --- /dev/null +++ b/lib/libc/wchar/wctob.c @@ -0,0 +1,16 @@ +#include <stdlib.h> +#include <wchar.h> +#include <stdio.h> + +#define IS_CODEUNIT(c) ((unsigned)(c) - 0xdf80 < 0x80) + +int wctob(wint_t c) +{ + if (c < 128U) + return (int)c; + + if (MB_CUR_MAX == 1 && IS_CODEUNIT(c)) + return (unsigned char)c; + + return EOF; +} |
