Commit 525e41c4 authored by mercury233's avatar mercury233

use setlocale if support

parent 73b5d3ca
...@@ -72,7 +72,12 @@ inline FILE* mywfopen(const wchar_t* filename, const char* mode) { ...@@ -72,7 +72,12 @@ inline FILE* mywfopen(const wchar_t* filename, const char* mode) {
return fp; return fp;
} }
#ifdef _WIN32 #if !defined(_WIN32)
#define myfopen std::fopen
#elif defined(WDK_NTDDI_VERSION) && (WDK_NTDDI_VERSION >= 0x0A000005) // Redstone 4, Version 1803, Build 17134.
#define FOPEN_WINDOWS_SUPPORT_UTF8
#define myfopen std::fopen
#else
inline FILE* myfopen(const char* filename, const char* mode) { inline FILE* myfopen(const char* filename, const char* mode) {
wchar_t wfilename[256]{}; wchar_t wfilename[256]{};
BufferIO::DecodeUTF8(filename, wfilename); BufferIO::DecodeUTF8(filename, wfilename);
...@@ -80,8 +85,6 @@ inline FILE* myfopen(const char* filename, const char* mode) { ...@@ -80,8 +85,6 @@ inline FILE* myfopen(const char* filename, const char* mode) {
BufferIO::CopyCharArray(mode, wmode); BufferIO::CopyCharArray(mode, wmode);
return _wfopen(wfilename, wmode); return _wfopen(wfilename, wmode);
} }
#else
#define myfopen std::fopen
#endif #endif
#include <irrlicht.h> #include <irrlicht.h>
......
...@@ -23,8 +23,10 @@ void ClickButton(irr::gui::IGUIElement* btn) { ...@@ -23,8 +23,10 @@ void ClickButton(irr::gui::IGUIElement* btn) {
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
#ifndef _WIN32 #if !defined(_WIN32)
std::setlocale(LC_CTYPE, "UTF-8"); std::setlocale(LC_CTYPE, "UTF-8");
#elif defined(FOPEN_WINDOWS_SUPPORT_UTF8)
setlocale(LC_CTYPE, ".UTF8");
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
CFURLRef bundle_url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef bundle_url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment