summaryrefslogtreecommitdiff
path: root/win32/stub.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-04 01:01:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-04 01:01:17 +0000
commit8bead2381521666a6cd1ad71fd0eab9e0f8617b7 (patch)
tree83b78cd72999631c7867515a6906156027f0b444 /win32/stub.c
parent8fb5a1aceb8a98fd1598a5c821614cbb0e1fa4e6 (diff)
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
Diffstat (limited to 'win32/stub.c')
-rw-r--r--win32/stub.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/win32/stub.c b/win32/stub.c
index 9c3659c..39bdcd9 100644
--- a/win32/stub.c
+++ b/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;