Skip to content

Commit

Permalink
Fix windows ANSI locale: use CP_ACP instead of CP_THREAD_ACP (#2062)
Browse files Browse the repository at this point in the history
* Fix windows ANSI locale: use CP_ACP instead of CP_THREAD_ACP

* Update Changes
  • Loading branch information
nojb authored and alainfrisch committed Oct 3, 2018
1 parent f04bbaf commit 1f25d35
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -490,6 +490,9 @@ Working version
- MPR#7408, MPR#7846, GPR#2015: Check arity of primitives.
(Hugo Heuzard, review by Nicolás Ojeda Bär)

- MPR#7854, GPR#2062: fix an issue where the wrong locale may be used when using
the legacy ANSI encoding under Windows.
(Nicolás Ojeda Bär, report by Tiphaine Turpin)

OCaml 4.07 maintenance branch
-----------------------------
Expand Down
6 changes: 3 additions & 3 deletions runtime/win32.c
Expand Up @@ -846,9 +846,9 @@ CAMLexport int win_multi_byte_to_wide_char(const char *s, int slen,
windows_unicode_strict ? MB_ERR_INVALID_CHARS : 0,
s, slen, out, outlen);
if (retcode == 0 && windows_unicode_fallback != 0)
retcode = MultiByteToWideChar(CP_THREAD_ACP, 0, s, slen, out, outlen);
retcode = MultiByteToWideChar(CP_ACP, 0, s, slen, out, outlen);
} else {
retcode = MultiByteToWideChar(CP_THREAD_ACP, 0, s, slen, out, outlen);
retcode = MultiByteToWideChar(CP_ACP, 0, s, slen, out, outlen);
}

if (retcode == 0)
Expand Down Expand Up @@ -879,7 +879,7 @@ CAMLexport int win_wide_char_to_multi_byte(const wchar_t *s, int slen,
s, slen, out, outlen, NULL, NULL);
else
retcode =
WideCharToMultiByte(CP_THREAD_ACP, 0, s, slen, out, outlen, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, s, slen, out, outlen, NULL, NULL);

if (retcode == 0)
caml_win32_sys_error(GetLastError());
Expand Down
2 changes: 1 addition & 1 deletion stdlib/headernt.c
Expand Up @@ -90,7 +90,7 @@ static BOOL WINAPI ctrl_handler(DWORD event)
#if WINDOWS_UNICODE
#define CP CP_UTF8
#else
#define CP CP_THREAD_ACP
#define CP CP_ACP
#endif

static void write_console(HANDLE hOut, WCHAR *wstr)
Expand Down

0 comments on commit 1f25d35

Please sign in to comment.