diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-10 13:16:49 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-10 13:46:52 +0100 |
commit | 4f277451362fdbb9f6930e57c50d3c2d0bbf45e5 (patch) | |
tree | 98a9160132638c4ad7754f8de820094e4ec6dc97 | |
parent | 680a873b765a502eb03498df381bd1ed5c217251 (diff) | |
download | serenity-4f277451362fdbb9f6930e57c50d3c2d0bbf45e5.zip |
LibC: Implement a very naive mbtowc()
This just copies the short char into the wide char without any decoding
whatsoever. A proper implementation should look at the current LC_CTYPE
and implement multi-byte decoding.
-rw-r--r-- | Libraries/LibC/stdlib.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Libraries/LibC/stdlib.cpp b/Libraries/LibC/stdlib.cpp index 3e2a8e1204..1ddbe66bfd 100644 --- a/Libraries/LibC/stdlib.cpp +++ b/Libraries/LibC/stdlib.cpp @@ -447,9 +447,21 @@ size_t mbstowcs(wchar_t*, const char*, size_t) ASSERT_NOT_REACHED(); } -size_t mbtowc(wchar_t*, const char*, size_t) +size_t mbtowc(wchar_t* wch, const char* data, size_t data_size) { - ASSERT_NOT_REACHED(); + // FIXME: This needs a real implementation. + UNUSED_PARAM(data_size); + + if (wch && data) { + *wch = *data; + return 1; + } + + if (!wch && data) { + return 1; + } + + return 0; } int wctomb(char*, wchar_t) |