Permalink
Browse files

Merge #7205 from justinmk/win-wmain

  • Loading branch information...
justinmk committed Aug 24, 2017
2 parents da84f7d + 02e5eaf commit 0f2873ce99437a0267eb777201f2e98f22757c2d
Showing with 7 additions and 13 deletions.
  1. +7 −13 src/nvim/main.c
@@ -220,24 +220,18 @@ void early_init(void)
#ifdef MAKE_LIB
int nvim_main(int argc, char **argv)
#elif defined WIN32
// don't use codepage encoded arguments. see #7060
int wmain(int argc, wchar_t **argv_w)
#elif defined(WIN32)
int wmain(int argc, wchar_t **argv_w) // multibyte args on Windows. #7060
#else
int main(int argc, char **argv)
#endif
{
#ifdef WIN32
#if defined(WIN32) && !defined(MAKE_LIB)
char *argv[argc];
for (size_t i = 0; i < (size_t)argc; i++) {
// get required buffer size
size_t dest_size = (size_t)WideCharToMultiByte(
CP_UTF8, 0, argv_w[i], -1, NULL, 0, NULL, NULL);
char *buf = (char *)xmallocz(dest_size);
// convert from utf16 (widechar) utf8 (multibyte)
WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, buf, (int)dest_size,
NULL, NULL);
for (int i = 0; i < argc; i++) {
char *buf = NULL;
utf16_to_utf8(argv_w[i], &buf);
assert(buf);
argv[i] = buf;
}
#endif

0 comments on commit 0f2873c

Please sign in to comment.