Fix the mbrtoc16 function reported here:

https://sourceforge.net/p/mingw-w64/bugs/957/

In contrast to mbrtoc32 which was only slightly misbehaving (now fixed),
mbrtoc16 is entirely broken, returning the UTF-8 bytes unchanged.

The proposed implementation in this patch has mbrtoc16 assume UTF-8
input, something which its mbrtoc32 counterpart has always been doing,
and reuses mbrtoc32 to simplify the implementation significantly, as it is
quite easy to get the UTF-16 code unit(s) once you have the UTF-32
code unit (Unicode code point value) first.

I also added tests for both functions, which are essentially taken from

https://en.cppreference.com/w/c/string/multibyte/mbrtoc16
https://en.cppreference.com/w/c/string/multibyte/mbrtoc32

with a little bit of added checking in the end.

I put the tests in a separate patch because I think adding them requires
re-generating mingw-w64-crt/Makefile.in and configure and I wasn't
sure how this is typically handled and if we even want to do that in this
case.

Thanks,
Costas

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to