sg16-unicode / sg16

SG16 overview and general information
45 stars 5 forks source link

Deprecate `btowc`, `wctob`, `mbtowc`, and `wctomb` #39

Open tahonermann opened 5 years ago

tahonermann commented 5 years ago

btowc and wctob are unable to provide conversions for code points that require multiple code units in variable length encodings. mbtowc and wctomb are able to handle code points that require multiple code units, but depend on global state and are therefore not thread safe. mbrtowc and wcrtomb have superseded both.

cubbimew commented 5 years ago

Note WG14 has a proposal to make mbtowc and wctomb thread-safe: n2281. Minutes say "Agree with the goal in principle" and "The paper needs more work"

tahonermann commented 5 years ago

@cubbimew Thank you for that link!

cubbimew commented 5 years ago

If btowc/wctob can be considered for deprecation, what about implicit conversions between char and wchar_t? Those are even more broken (they are basically btowc/wctob minus error-checking) and more sneaky (e.g. they let you construct a garbage wstring from a string iterator pair)

tahonermann commented 5 years ago

I agree those conversions are more broken. I don't know how realistic it would be to make changes for wchar_t (and char16_t and char32_t), but it would be nice it we could. I've been leaning more towards leaving code unit/code point types as is and introducing new "character" types that are not integral types and do not participate in the traditional integral promotions/conversions.