aboutsummaryrefslogtreecommitdiffstats
path: root/src/console.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-07-31 20:06:15 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commit70036e2a0d7ca13ef9a126be4e751fc5768613b6 (patch)
tree018f152719734ad7a6d22a84aadb7ddda25ab591 /src/console.c
parentd76b4da8f420a320b830544288c555a284151773 (diff)
downloadserd-70036e2a0d7ca13ef9a126be4e751fc5768613b6.tar.gz
serd-70036e2a0d7ca13ef9a126be4e751fc5768613b6.tar.bz2
serd-70036e2a0d7ca13ef9a126be4e751fc5768613b6.zip
Factor out Windows UTF-8 console setup code
Diffstat (limited to 'src/console.c')
-rw-r--r--src/console.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/console.c b/src/console.c
new file mode 100644
index 00000000..a15c8e7d
--- /dev/null
+++ b/src/console.c
@@ -0,0 +1,22 @@
+// Copyright 2011-2021 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#include "console.h"
+
+#ifdef _WIN32
+# ifdef _MSC_VER
+# define WIN32_LEAN_AND_MEAN 1
+# endif
+# include <fcntl.h>
+# include <io.h>
+#endif
+
+void
+serd_set_stream_utf8_mode(FILE* const stream)
+{
+#ifdef _WIN32
+ _setmode(_fileno(stream), _O_BINARY);
+#else
+ (void)stream;
+#endif
+}