1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

stub.c: utf-8

* win32/stub.c (stub_sysinit): encode in UTF-8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-04-04 01:01:17 +00:00
parent 8fb5a1aceb
commit 8bead23815

View file

@ -7,12 +7,14 @@ static void stub_sysinit(int *argc, char ***argv);
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)
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;