diff --git a/Userland/Libraries/LibC/stdlib.cpp b/Userland/Libraries/LibC/stdlib.cpp index 2bf5497f35..101a2e670a 100644 --- a/Userland/Libraries/LibC/stdlib.cpp +++ b/Userland/Libraries/LibC/stdlib.cpp @@ -29,6 +29,7 @@ #include #include #include +#include static void strtons(const char* str, char** endptr) { @@ -898,10 +899,15 @@ int mbtowc(wchar_t* wch, const char* data, [[maybe_unused]] size_t data_size) return 0; } -int wctomb(char*, wchar_t) +int wctomb(char* s, wchar_t wc) { - dbgln("FIXME: Implement wctomb()"); - TODO(); + static mbstate_t _internal_state = {}; + + // nullptr asks whether we have state-dependent encodings, but we don't have any. + if (s == nullptr) + return 0; + + return static_cast(wcrtomb(s, wc, &_internal_state)); } size_t wcstombs(char* dest, const wchar_t* src, size_t max)