[libcxx-commits] [libcxx] [libc++] Avoid calling `setlocale` in `do_unshift` when unnecessary (PR #117153)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 19 09:04:42 PST 2024


https://github.com/ldionne commented:

I'm not the best person to review this PR because I'm not very well-versed in locales and all this multibyte character fun. But this seems correct to me based on [cppreference's interpretation of the Standard](https://en.cppreference.com/w/cpp/locale/codecvt/unshift), which is better than nothing:

> If the encoding represented by this codecvt facet is state-dependent, and state represents a conversion state that is not the initial shift state, writes the characters necessary to return to the initial shift state.

[The _effects_](http://eel.is/c++draft/locale.codecvt.virtuals#8) in the actual Standard don't mention this specifically but I assume this is obvious to anyone more familiar with this API.

It would be nice to get a short review from someone like @tahonermann or @mstorsjo.

Assuming this is functionally correct, I have no objection about short-circuiting in this function to minimize the impact of the linked bug.

https://github.com/llvm/llvm-project/pull/117153


More information about the libcxx-commits mailing list