From c2077356ad2dbe9a2cfa50be74790443a512c345 Mon Sep 17 00:00:00 2001 From: Vadim Grigoruk Date: Fri, 24 Aug 2018 23:42:37 +0300 Subject: [PATCH] #664 fixed utf16<=>utf8 conversion --- src/fs.c | 4 ++-- src/studio.c | 3 --- src/system.c | 6 +++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/fs.c b/src/fs.c index f0fd1e9..62a4759 100644 --- a/src/fs.c +++ b/src/fs.c @@ -115,7 +115,7 @@ static const fsString* utf8ToString(const char* str) { fsString* wstr = malloc(FILENAME_MAX * sizeof(fsString)); - mbstowcs(wstr, str, FILENAME_MAX); + MultiByteToWideChar(CP_UTF8, 0, str, FILENAME_MAX, wstr, FILENAME_MAX); return wstr; } @@ -124,7 +124,7 @@ static const char* stringToUtf8(const fsString* wstr) { char* str = malloc(FILENAME_MAX * sizeof(char)); - wcstombs(str, wstr, FILENAME_MAX); + WideCharToMultiByte(CP_UTF8, 0, wstr, FILENAME_MAX, str, FILENAME_MAX, 0, 0); return str; } diff --git a/src/studio.c b/src/studio.c index eaa6bfa..8368cb1 100644 --- a/src/studio.c +++ b/src/studio.c @@ -49,8 +49,6 @@ #include #include -#include - #define FRAME_SIZE (TIC80_FULLWIDTH * TIC80_FULLHEIGHT * sizeof(u32)) #define POPUP_DUR (TIC_FRAMERATE*2) @@ -1819,7 +1817,6 @@ static void studioClose() Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* folder, System* system) { - setlocale(LC_CTYPE, ""); setbuf(stdout, NULL); impl.argc = argc; impl.argv = argv; diff --git a/src/system.c b/src/system.c index c297d8c..bfd161f 100644 --- a/src/system.c +++ b/src/system.c @@ -20,6 +20,10 @@ #define KBD_COLS 22 #define KBD_ROWS 17 +#if defined(__TIC_WINRT__) || defined(__TIC_WINDOWS__) +#include +#endif + static struct { Studio* studio; @@ -1202,7 +1206,7 @@ static void openSystemPath(const char* path) sprintf(command, "explorer \"%s\"", path); wchar_t wcommand[FILENAME_MAX]; - mbstowcs(wcommand, command, FILENAME_MAX); + MultiByteToWideChar(CP_UTF8, 0, command, FILENAME_MAX, wcommand, FILENAME_MAX); _wsystem(wcommand);