Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows ANSI locale: use CP_ACP instead of CP_THREAD_ACP #2062

Merged
merged 2 commits into from Oct 3, 2018

Conversation

Projects
None yet
2 participants
@nojb
Copy link
Contributor

commented Sep 24, 2018

See MPR#7854.

It would be nice to include this in 4.07.1; @damiendoligez ?

nojb added some commits Sep 24, 2018

@alainfrisch alainfrisch added this to the 4.07.1 milestone Sep 26, 2018

@alainfrisch

This comment has been minimized.

Copy link
Contributor

commented Sep 26, 2018

The fix looks ok given the reference you mention in the Mantis ticket. Have you been able to reproduce the original bug, to confirm it is indeed fixed by the change?

@nojb

This comment has been minimized.

Copy link
Contributor Author

commented Sep 28, 2018

Yes, I tested as follows, with Windows 10 English (US) and OCaml compiled with WINDOWS_UNICODE=0:

  • Changed the "Region & Language" setting to "Russian"
  • Wrote the following into a Latin-1-encoded file:
let () = close_out (open_out "éé");;
  • Run the file with ocaml before this PR: it creates a file named йй.
  • Run the file with ocaml after this PR: it creates a file named éé.
  • Run the following C program and check that it creates a file named éé:
#include <Windows.h>
int main(void)
{
  CreateFileA("éé", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  return 0;
}

(again, the file is encoded in Latin-1)

The conclusion of this experiment is coherent with the assertion that CP_THREAD_ACP does not match the encoding used by the "A" functions in general, and that CP_ACP should be used instead.

@alainfrisch alainfrisch merged commit 1f25d35 into ocaml:trunk Oct 3, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@alainfrisch

This comment has been minimized.

Copy link
Contributor

commented Oct 3, 2018

Still interested in @damiendoligez 's opinion about cherry-picking for 4.07.1.

damiendoligez added a commit to damiendoligez/ocaml that referenced this pull request Nov 5, 2018

Fix windows ANSI locale: use CP_ACP instead of CP_THREAD_ACP (ocaml#2062
)

* Fix windows ANSI locale: use CP_ACP instead of CP_THREAD_ACP

* Update Changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.