llvm-capstone/libcxx
Martin Storsjö fcbbd9649a [libcxx] Fix using std::wcout/wcin on Windows with streams configured in wide mode
On Windows, the underlying file descriptors for stdout/stdin/stderr
can be reconfigured to wide mode. In the default (narrow) mode, the
charset usually isn't utf8 (as libcxx assumes), but normally a locale
specific codepage (where each codepage only can represent a small
subset of unicode characters).

By configuring the stdout file descriptor to wide mode, the user can
output wchar_t based strings without convesion to the narrow charset.
Within libcxx, don't try to use codecvt to convert this to a narrow
character encoding, but output these strings as such with fputwc.

In wide mode, such strings could be output directly with fwrite too,
but if the file descriptor hasn't been configured in wide mode, that
breaks the output (which currently works reasonably). By always
outputting one character at a time with fputwc, it works regardless
of mode of the stdout file descriptor.

For the narrow output stream, std::cout, outputting (via fwrite)
does fail when the file descriptor is set to wide mode. This matches
how it behaves with both MS STL and GNU libstdc++ too, so this is
probably acceptable.

This fixes https://github.com/llvm/llvm-project/issues/46646, and
the downstream bugs https://github.com/mstorsjo/llvm-mingw/issues/145
and https://github.com/mstorsjo/llvm-mingw/issues/222.

Differential Revision: https://reviews.llvm.org/D146398
2023-06-03 23:11:39 +03:00
..
benchmarks [libc++] Optimize for_each for segmented iterators 2023-05-31 18:15:25 -07:00
cmake [libc++] Adds C++26 support. 2023-05-24 07:49:19 +02:00
docs [libcxx] Fix using std::wcout/wcin on Windows with streams configured in wide mode 2023-06-03 23:11:39 +03:00
include [libc++][PSTL] Implement std::stable_sort 2023-06-01 15:07:28 -07:00
lib [libc++] Remove symbols for a std::allocator_arg & friends from the dylib 2023-04-19 17:27:14 -04:00
modules [libc++][modules] Adds std module cppm files. 2023-05-23 18:51:27 +02:00
src [libcxx] Fix using std::wcout/wcin on Windows with streams configured in wide mode 2023-06-03 23:11:39 +03:00
test [libcxx] Fix using std::wcout/wcin on Windows with streams configured in wide mode 2023-06-03 23:11:39 +03:00
utils [libc++] Transition several remaining generated tests to the new .gen format 2023-06-02 10:02:15 -07:00
.clang-format [libc++] Remove _LIBCPP_CONSTEVAL 2023-03-10 09:04:48 -05:00
.clang-tidy [libc++] Enable radability-identifier-naming for local variables and fix any problems 2023-02-11 20:03:53 +01:00
.gitignore
appveyor-reqs-install.cmd
appveyor.yml [libc++] Re-apply "Always build c++experimental.a"" 2022-07-19 10:44:19 -04:00
CMakeLists.txt Reland "[CMake] Bumps minimum version to 3.20.0. 2023-05-27 12:51:21 +02:00
CREDITS.TXT [libcxx] Add mdspan/extents 2023-05-16 14:30:36 -07:00
LICENSE.TXT
TODO.TXT