diff options
author | Tim Schumacher <timschumi@gmx.de> | 2021-06-05 02:23:53 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-16 16:42:40 +0200 |
commit | 405f3d0aa3be30de6892bc9ea9303f0611ede5f6 (patch) | |
tree | 2d9634172eefb62913b075e6bb2270a662f8b696 /Userland/Libraries/LibC/wchar.cpp | |
parent | e4fa9c917e4f12a6f0ef972f39e01a2ddd993f3a (diff) | |
download | serenity-405f3d0aa3be30de6892bc9ea9303f0611ede5f6.zip |
LibC: Implement btowc()
Diffstat (limited to 'Userland/Libraries/LibC/wchar.cpp')
-rw-r--r-- | Userland/Libraries/LibC/wchar.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Userland/Libraries/LibC/wchar.cpp b/Userland/Libraries/LibC/wchar.cpp index 726d998bc9..b3bca30b3f 100644 --- a/Userland/Libraries/LibC/wchar.cpp +++ b/Userland/Libraries/LibC/wchar.cpp @@ -154,10 +154,18 @@ long long wcstoll(const wchar_t*, wchar_t**, int) TODO(); } -wint_t btowc(int) +wint_t btowc(int c) { - dbgln("FIXME: Implement btowc()"); - TODO(); + if (c == EOF) { + return WEOF; + } + + // Multi-byte sequences in UTF-8 have their highest bit set + if (c & (1 << 7)) { + return WEOF; + } + + return c; } size_t mbrtowc(wchar_t*, const char*, size_t, mbstate_t*) |