From fc00c656c96528112d05cf0edf8631bd5eaea446 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 7 Dec 2025 20:10:31 +0100 Subject: Add build system scaffolding and libc headers --- lib/libc/wchar/wctob.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/libc/wchar/wctob.c (limited to 'lib/libc/wchar/wctob.c') 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 +#include +#include + +#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; +} -- cgit v1.2.3