[Bug 37402] New: WINAPI is not correct
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(a)winehq.org Reporter: k1-801(a)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. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37402 --- Comment #1 from Nikolay Sivov <bunglehead(a)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. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37402 Hao Peng <penghao(a)linuxdeepin.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |penghao(a)linuxdeepin.com -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37402 Ken Sharp <imwellcushtymelike(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37402 Alex Henrie <alexhenrie24(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |kernel32 CC| |alexhenrie24(a)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(a)gmail.com> --- Still present in Wine 2.3; I'm working on a patch. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37402 Alex Henrie <alexhenrie24(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Fixed by SHA1| |0b95ebd283986fa179c7ec6d2ea | |3f34c977c3aaf Resolution|--- |FIXED --- Comment #3 from Alex Henrie <alexhenrie24(a)gmail.com> --- Fixed by https://source.winehq.org/git/wine.git/commitdiff/0b95ebd283986fa179c7ec6d2e... -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37402 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #4 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 2.5. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37402 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |2.0.x -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37402 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|2.0.x |--- --- Comment #5 from Michael Stefaniuc <mstefani(a)winehq.org> --- Remove 2.0.x milestone. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
wine-bugs@winehq.org