https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048
Carlos O'Donell changed:
What|Removed |Added
CC||carlos at redhat dot com
--- Comment #2 from Carlos O'Donell ---
(In reply to Jonathan Wakely from comment #1)
> This happens because glibc won't convert the wide string to UTF-8:
>
> #include
> #include
>
> int main()
> {
> const wchar_t wstr[] = L"ä";
> const wchar_t* from = wstr;
> char to[10];
> mbstate_t s;
> size_t res = wcsnrtombs(to, , 1, sizeof(to), );
> 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.