From 665347213daf0bf0b4871335fcfec4f08ffc7620 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 9 Nov 2023 20:17:11 +0300 Subject: [PATCH] Added util/platform module --- src/util/platform.cpp | 14 ++++++++++++++ src/util/platform.h | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/util/platform.cpp create mode 100644 src/util/platform.h diff --git a/src/util/platform.cpp b/src/util/platform.cpp new file mode 100644 index 00000000..fd55a5f3 --- /dev/null +++ b/src/util/platform.cpp @@ -0,0 +1,14 @@ +#include "platform.h" + +#ifdef WIN32 +#include + +void platform::configure_encoding() { + // set utf-8 encoding to console output + SetConsoleOutputCP(CP_UTF8); + setvbuf(stdout, nullptr, _IOFBF, 1000); +} +#else +void platform::configure_encoding(){ +} +#endif \ No newline at end of file diff --git a/src/util/platform.h b/src/util/platform.h new file mode 100644 index 00000000..9e7952d1 --- /dev/null +++ b/src/util/platform.h @@ -0,0 +1,8 @@ +#ifndef UTIL_PLATFORM_H_ +#define UTIL_PLATFORM_H_ + +namespace platform { + extern void configure_encoding(); +} + +#endif // UTIL_PLATFORM_H_ \ No newline at end of file