diff options
Diffstat (limited to 'src/w32.c')
-rw-r--r-- | src/w32.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/w32.c b/src/w32.c index 7884bad619c..6f1d5fd1698 100644 --- a/src/w32.c +++ b/src/w32.c @@ -486,6 +486,7 @@ typedef DWORD (WINAPI *GetAdaptersInfo_Proc) ( int (WINAPI *pMultiByteToWideChar)(UINT,DWORD,LPCSTR,int,LPWSTR,int); int (WINAPI *pWideCharToMultiByte)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL); +DWORD multiByteToWideCharFlags; /* ** A utility function ** */ static BOOL @@ -1552,8 +1553,8 @@ codepage_for_filenames (CPINFO *cp_info) int filename_to_utf16 (const char *fn_in, wchar_t *fn_out) { - int result = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, fn_in, -1, - fn_out, MAX_PATH); + int result = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, fn_in, + -1, fn_out, MAX_PATH); if (!result) { @@ -1643,8 +1644,8 @@ filename_from_ansi (const char *fn_in, char *fn_out) { wchar_t fn_utf16[MAX_PATH]; int codepage = codepage_for_filenames (NULL); - int result = pMultiByteToWideChar (codepage, MB_ERR_INVALID_CHARS, fn_in, -1, - fn_utf16, MAX_PATH); + int result = pMultiByteToWideChar (codepage, multiByteToWideCharFlags, fn_in, + -1, fn_utf16, MAX_PATH); if (!result) { @@ -9134,14 +9135,14 @@ check_windows_init_file (void) "not unpacked properly.\nSee the README.W32 file in the " "top-level Emacs directory for more information.", init_file_name, load_path); - needed = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, buffer, - -1, NULL, 0); + needed = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, + buffer, -1, NULL, 0); if (needed > 0) { wchar_t *msg_w = alloca ((needed + 1) * sizeof (wchar_t)); - pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, buffer, -1, - msg_w, needed); + pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, buffer, + -1, msg_w, needed); needed = pWideCharToMultiByte (CP_ACP, 0, msg_w, -1, NULL, 0, NULL, NULL); if (needed > 0) @@ -9328,6 +9329,7 @@ maybe_load_unicows_dll (void) (MultiByteToWideChar_Proc)GetProcAddress (ret, "MultiByteToWideChar"); pWideCharToMultiByte = (WideCharToMultiByte_Proc)GetProcAddress (ret, "WideCharToMultiByte"); + multiByteToWideCharFlags = MB_ERR_INVALID_CHARS; return ret; } else @@ -9357,6 +9359,11 @@ maybe_load_unicows_dll (void) pointers; no need for the LoadLibrary dance. */ pMultiByteToWideChar = MultiByteToWideChar; pWideCharToMultiByte = WideCharToMultiByte; + /* On NT 4.0, though, MB_ERR_INVALID_CHARS is not supported. */ + if (w32_major_version < 5) + multiByteToWideCharFlags = 0; + else + multiByteToWideCharFlags = MB_ERR_INVALID_CHARS; return LoadLibrary ("Gdi32.dll"); } } |