aboutsummaryrefslogtreecommitdiff
path: root/lib/fstream/unix
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-03-10 21:22:36 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-03-10 21:53:29 +0100
commit6447b191eef8bf8f4942569e55c9a0f297c67a8e (patch)
tree8d38fa052c522ac4cfd9440c1c5297fce0571f5c /lib/fstream/unix
parent8b0e45bd2cf2ae97d26e7922f9dbf6c9903bb7c6 (diff)
Windows: redirect standard I/O and convert text to UTF-16
Preprocessor magic is used to redirect putc/fputc/fputs/printf/fprintf to custom implementations. The custom implementations try to figure out if we are printing to the console and, if so, convert the resulting strings to UTF-16 and print them through ConsoleWriteW. If the output is redirected to a file or a pipe, the original (presummed) UTF-8 is kept. Simply setting the console output codepage to UTF-8 does not work, because the standard I/O facilities of MSVCRT either does not support unicode (in non-wchar mode), or has half-broken support through fputs, which can still break up multi-byte sequences through its internal buffering. Likewise, changing the codepage and using ConsoleWriteA, or trying to use fputws did not work in a test VM either. This approach is the one that worked most consistently among the ones tried, but also has problems. E.g. it breaks when setting the codepage to UTF-8 manually (using `chcp 65001`). Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstream/unix')
0 files changed, 0 insertions, 0 deletions