https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048
Carlos O'Donell <carlos at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |carlos at redhat dot com --- Comment #2 from Carlos O'Donell <carlos at redhat dot com> --- (In reply to Jonathan Wakely from comment #1) > This happens because glibc won't convert the wide string to UTF-8: > > #include <wchar.h> > #include <assert.h> > > int main() > { > const wchar_t wstr[] = L"รค"; > const wchar_t* from = wstr; > char to[10]; > mbstate_t s; > size_t res = wcsnrtombs(to, &from, 1, sizeof(to), &s); > assert(res != (size_t)-1); > } > > I'm not yet sure why glibc refuses to convert that. ISO C says: "At program startup, the equivalent of setlocale(LC_ALL, "C"); is executed." Which means you are trying to convert UTF-8 to ASCII. You should call setlocale with a non-ASCII character set to make this work.