From 43c41fc9f9f96a2e30224a2b454af109ce07fbb1 Mon Sep 17 00:00:00 2001 From: yg2f Date: Mon, 4 May 2015 20:26:49 +0200 Subject: [PATCH] fixes issue #1693 winmain and main unicode makes WinMain() and main() accepts unicode characters into arguments --- platform/windows/godot_win.cpp | 115 +++++++++------------------------ 1 file changed, 29 insertions(+), 86 deletions(-) diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp index 0e74f63510..81c90d9dd0 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_win.cpp @@ -115,29 +115,24 @@ PCHAR* return argv; } -char* mb_to_utf8(const char* mbs) { - - int wlen = MultiByteToWideChar(CP_ACP,0,mbs,-1,NULL,0); // returns 0 if failed - wchar_t *wbuf = new wchar_t[wlen + 1]; - MultiByteToWideChar(CP_ACP,0,mbs,-1,wbuf,wlen); - wbuf[wlen]=0; - - int ulen = WideCharToMultiByte(CP_UTF8,0,wbuf,-1,NULL,0,NULL,NULL); +char* wc_to_utf8(const wchar_t* wc) { + int ulen = WideCharToMultiByte(CP_UTF8,0,wc,-1,NULL,0,NULL,NULL); char * ubuf = new char[ulen + 1]; - WideCharToMultiByte(CP_UTF8,0,wbuf,-1,ubuf,ulen,NULL,NULL); + WideCharToMultiByte(CP_UTF8,0,wc,-1,ubuf,ulen,NULL,NULL); ubuf[ulen] = 0; return ubuf; } -int main(int argc, char** argv) { +int widechar_main(int argc, wchar_t** argv) { OS_Windows os(NULL); setlocale(LC_CTYPE, ""); char ** argv_utf8 = new char*[argc]; + for(int i=0; i