https://bugs.winehq.org/show_bug.cgi?id=37402
Bug ID: 37402 Summary: WINAPI is not correct Product: Wine Version: unspecified Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: k1-801@mail.ru Distribution: ---
I've found a strang bug while testing my program. I used few WINAPI funcs for codepage converting (the file path was in UTF-8, and to open it, I needed to convert it to the Windows's awkward wchar_t and back). I hadn't a copy of Windows that time, so I tested it on wine. There's the tested code:
char* WcharToUTF8(wchar_t *in) { uint64_t len = WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, in, -1, NULL, 0, NULL, NULL); char *out = (char*)calloc((len + 1) * 6, sizeof(char)); WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, in, -1, out, len, NULL, NULL); return out; }
It worked on wine. On wine it returns correctly converted string. On real Windows it returns nothing, and empty string crashes the program. After replasing MB_ERR_INVALID_CHARS with 0 it worked on both wine and Windows.
char* WcharToUTF8(wchar_t *in) { uint64_t len = WideCharToMultiByte(CP_UTF8, 0, in, -1, NULL, 0, NULL, NULL); char *out = (char*)calloc(len + 1, sizeof(char)); WideCharToMultiByte(CP_UTF8, 0, in, -1, out, len, NULL, NULL); return out; }
Also, the code was stolen from MSDN page about codepages, and there was a note about "nothing will work correctly WITHOUT MB_ERR_INVALID_CHARS".
Windows bug? Wine bug? Wine did work as said in MSDN, Windows did not.
https://bugs.winehq.org/show_bug.cgi?id=37402
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com --- You're doing it wrong. For WideCharToMultiByte() you need to use WC_ERR_INVALID_CHARS flag. Also try to avoid wchar_t. It's possible that Wine should work too in your case, simply rejecting invalid flags, but that needs test.
https://bugs.winehq.org/show_bug.cgi?id=37402
Hao Peng penghao@linuxdeepin.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |penghao@linuxdeepin.com
https://bugs.winehq.org/show_bug.cgi?id=37402
Ken Sharp imwellcushtymelike@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source
https://bugs.winehq.org/show_bug.cgi?id=37402
Alex Henrie alexhenrie24@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |kernel32 CC| |alexhenrie24@gmail.com Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Version|unspecified |2.3 Summary|WINAPI is not correct |WideCharToMultiByte is | |supposed to reject invalid | |flags
--- Comment #2 from Alex Henrie alexhenrie24@gmail.com --- Still present in Wine 2.3; I'm working on a patch.
https://bugs.winehq.org/show_bug.cgi?id=37402
Alex Henrie alexhenrie24@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Fixed by SHA1| |0b95ebd283986fa179c7ec6d2ea | |3f34c977c3aaf Resolution|--- |FIXED
--- Comment #3 from Alex Henrie alexhenrie24@gmail.com --- Fixed by https://source.winehq.org/git/wine.git/commitdiff/0b95ebd283986fa179c7ec6d2e...
https://bugs.winehq.org/show_bug.cgi?id=37402
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #4 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 2.5.
https://bugs.winehq.org/show_bug.cgi?id=37402
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |2.0.x
https://bugs.winehq.org/show_bug.cgi?id=37402
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|2.0.x |---
--- Comment #5 from Michael Stefaniuc mstefani@winehq.org --- Remove 2.0.x milestone.