Windows7: the flags passed to widetomultichar was not correct.
Also no wmain with our mingw version.
This commit is contained in:
parent
2d96fea11e
commit
cd29fd581d
@ -548,7 +548,13 @@ static void flushIdxReasons()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
// With more recent versions of mingw, we could use -municode to
|
||||
// enable wmain. Another workaround is to use main, then call
|
||||
// GetCommandLineW and CommandLineToArgvW, to then call wmain(). If
|
||||
// ever we need to build with mingw again.
|
||||
#define USE_WMAIN (defined(_WIN32) && defined(_MSC_VER))
|
||||
|
||||
#if USE_WMAIN
|
||||
#define WARGTOSTRING(w) wchartoutf8(w)
|
||||
static vector<string> argstovector(int argc, wchar_t **argv)
|
||||
#else
|
||||
@ -578,14 +584,15 @@ static vector<string> fileToArgs(const string& fn)
|
||||
return args;
|
||||
}
|
||||
|
||||
// A bit of history: it's difficult to pass non-ascii parameters
|
||||
|
||||
// A bit of history: it's difficult to pass non-ASCII parameters
|
||||
// (e.g. path names) on the command line under Windows without using
|
||||
// Unicode. It was first thought possible to use a temporary file to
|
||||
// hold the args, and make sure that the path for this would be ASCII,
|
||||
// based on using shortpath(). Unfortunately, this does not work in
|
||||
// all cases, so the second change was to use wmain(), but the
|
||||
// now largely redundant args-in-file passing trick was kept anyway.
|
||||
#ifdef _WIN32
|
||||
#if USE_WMAIN
|
||||
int wmain(int argc, wchar_t *argv[])
|
||||
#else
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@ -180,11 +180,12 @@ bool wchartoutf8(const wchar_t *in, std::string& out, size_t wlen)
|
||||
if (wlen == 0) {
|
||||
wlen = wcslen(in);
|
||||
}
|
||||
int flags = WC_ERR_INVALID_CHARS|WC_NO_BEST_FIT_CHARS;
|
||||
int flags = WC_ERR_INVALID_CHARS;
|
||||
int bytes = ::WideCharToMultiByte(
|
||||
CP_UTF8, flags, in, wlen, nullptr, 0, nullptr, nullptr);
|
||||
if (bytes <= 0) {
|
||||
LOGERR("wchartoutf8: conversion error1\n");
|
||||
fwprintf(stderr, L"wchartoutf8: conversion error1 for [%s]\n", in);
|
||||
return false;
|
||||
}
|
||||
char *cp = (char *)malloc(bytes+1);
|
||||
@ -202,6 +203,8 @@ bool wchartoutf8(const wchar_t *in, std::string& out, size_t wlen)
|
||||
cp[bytes] = 0;
|
||||
out = cp;
|
||||
free(cp);
|
||||
fwprintf(stderr, L"wchartoutf8: in: [%s]\n", in);
|
||||
fprintf(stderr, "wchartoutf8: out: [%s]\n", out.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user