diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2022-03-10 21:22:36 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2022-03-10 21:53:29 +0100 |
commit | 6447b191eef8bf8f4942569e55c9a0f297c67a8e (patch) | |
tree | 8d38fa052c522ac4cfd9440c1c5297fce0571f5c /lib/compat/Makemodule.am | |
parent | 8b0e45bd2cf2ae97d26e7922f9dbf6c9903bb7c6 (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/compat/Makemodule.am')
-rw-r--r-- | lib/compat/Makemodule.am | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/compat/Makemodule.am b/lib/compat/Makemodule.am index f9dce2e..0426075 100644 --- a/lib/compat/Makemodule.am +++ b/lib/compat/Makemodule.am @@ -4,6 +4,7 @@ libcompat_a_SOURCES += lib/compat/chdir.c include/compat.h libcompat_a_SOURCES += lib/compat/path_to_windows.c libcompat_a_SOURCES += lib/compat/w32_perror.c libcompat_a_SOURCES += lib/compat/w32_wmain.c +libcompat_a_SOURCES += lib/compat/w32_stdio.c libcompat_a_SOURCES += lib/compat/fnmatch.c libcompat_a_SOURCES += lib/compat/getopt.c libcompat_a_SOURCES += lib/compat/getopt_long.c |