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:
parent
8fb5a1aceb
commit
8bead23815
1 changed files with 6 additions and 4 deletions
10
win32/stub.c
10
win32/stub.c
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue