int win32_cmdline_utf8(int * argc, char *** argv) { int argcounter; wchar_t **argv_wide; wchar_t **env; char *argvptr; _startupinfo startup; /* That's too lame. */ if(argv == NULL || argc == NULL) return -1; startup.newmode = 0; __wgetmainargs(argc, &argv_wide,&env,1, &startup); *argv = (char **)calloc(sizeof (char *), *argc); if(*argv == NULL) { error("Cannot allocate memory for command line."); return -1; } for(argcounter = 0; argcounter < *argc; argcounter++) { win32_wide_utf8(argv_wide[argcounter], &argvptr, NULL); (*argv)[argcounter] = argvptr; } return 0; }
int win32_cmdline_utf8(int * argc, char *** argv) { wchar_t **argv_wide; char *argvptr; int argcounter; /* That's too lame. */ if(argv == NULL || argc == NULL) return -1; argv_wide = CommandLineToArgvW(GetCommandLineW(), argc); if(argv_wide == NULL){ error("Cannot get wide command line."); return -1; } *argv = (char **)calloc(sizeof (char *), *argc); if(*argv == NULL){ error("Cannot allocate memory for command line."); return -1; } for(argcounter = 0; argcounter < *argc; argcounter++) { win32_wide_utf8(argv_wide[argcounter], &argvptr, NULL); (*argv)[argcounter] = argvptr; } LocalFree(argv_wide); /* We don't need it anymore */ return 0; }