ruby-changes:38079
From: nobu <ko1@a...>
Date: Sat, 4 Apr 2015 10:01:43 +0900 (JST)
Subject: [ruby-changes:38079] nobu:r50160 (trunk): stub.c: utf-8
nobu 2015-04-04 10:01:17 +0900 (Sat, 04 Apr 2015) New Revision: 50160 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50160 Log: stub.c: utf-8 * win32/stub.c (stub_sysinit): encode in UTF-8. Modified files: trunk/win32/stub.c Index: win32/stub.c =================================================================== --- win32/stub.c (revision 50159) +++ win32/stub.c (revision 50160) @@ -7,12 +7,14 @@ static void stub_sysinit(int *argc, char https://github.com/ruby/ruby/blob/trunk/win32/stub.c#L7 void stub_sysinit(int *argc, char ***argv) { - char exename[4096]; - size_t lenexe, len0, lenall; + WCHAR exename[4096]; + size_t wlenexe, len0, lenall; + int lenexe; int i, ac; char **av, *p; - lenexe = (size_t)GetModuleFileName(NULL, exename, sizeof exename); + wlenexe = (size_t)GetModuleFileNameW(NULL, exename, sizeof(exename) / sizeof(*exename)); + lenexe = WideCharToMultiByte(CP_UTF8, 0, exename, wlenexe, NULL, 0, NULL, NULL); ruby_sysinit(argc, argv); ac = *argc; av = *argv; @@ -33,7 +35,7 @@ stub_sysinit(int *argc, char ***argv) https://github.com/ruby/ruby/blob/trunk/win32/stub.c#L35 memmove(p, (char *)(av + ac), len0); *av++ = p; p += len0; - memcpy(p, exename, lenexe); + WideCharToMultiByte(CP_UTF8, 0, exename, wlenexe, p, lenexe, NULL, NULL); p[lenexe] = '\0'; *av++ = p; p += lenexe + 1; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/