https://bugs.winehq.org/show_bug.cgi?id=40043
Bug ID: 40043 Summary: WideCharToMultiByte not converting correctly Product: Wine Version: 1.8 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: wolf+wine@wolfsden.cz Distribution: ---
Created attachment 53501 --> https://bugs.winehq.org/attachment.cgi?id=53501 short program illustrating the problem
I'm trying to use WideCharToMultiByte function for encoding conversions and I'm getting incorrect output. Same program compiled under Visual Studio on Windows 7 returns expected result.
sample.cpp - short program illustrating the problem vc_output - output of the program from visual studio wine_output - output from development version of wine
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #1 from Wolf wolf+wine@wolfsden.cz --- Created attachment 53502 --> https://bugs.winehq.org/attachment.cgi?id=53502 output of visual studio&windows version
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #2 from Wolf wolf+wine@wolfsden.cz --- Created attachment 53503 --> https://bugs.winehq.org/attachment.cgi?id=53503 output of wine version
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #3 from Nikolay Sivov bunglehead@gmail.com --- Is this with statically linked C/C++ runtime libraries? Please attach built exe too.
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #4 from Wolf wolf+wine@wolfsden.cz --- Created attachment 53504 --> https://bugs.winehq.org/attachment.cgi?id=53504 launcher script
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #5 from Wolf wolf+wine@wolfsden.cz --- Created attachment 53505 --> https://bugs.winehq.org/attachment.cgi?id=53505 compiler binary
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #6 from Wolf wolf+wine@wolfsden.cz --- files added, compiled with following line:
wineg++ -std=c++11 sample.cpp
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #7 from Nikolay Sivov bunglehead@gmail.com --- I meant binary that I can run on Windows.
https://bugs.winehq.org/show_bug.cgi?id=40043
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #8 from Wolf wolf+wine@wolfsden.cz --- Created attachment 53507 --> https://bugs.winehq.org/attachment.cgi?id=53507 executable created with visual studio 2015
https://bugs.winehq.org/show_bug.cgi?id=40043
Detlef Riekenberg wine.dev@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|WideCharToMultiByte not |wineg++ creates |converting correctly |bInitialization of a | |wstring Ever confirmed|0 |1 Status|UNCONFIRMED |NEW
--- Comment #9 from Detlef Riekenberg wine.dev@web.de --- The executable created with visual studio 2015 works without any failure in wine. So the bug has nothing to do with WideCharToMultiByte.
A hint for the bug is visible in the log: "input size" is not 11.
Verified with a stripped down example: * The static initialization of the wstring fails with wineg++ * Using g++ works without faulure.
https://bugs.winehq.org/show_bug.cgi?id=40043
Detlef Riekenberg wine.dev@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|wineg++ creates |Initialization of a wstring |bInitialization of a |fails with wineg++ |wstring |
https://bugs.winehq.org/show_bug.cgi?id=40043
Detlef Riekenberg wine.dev@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #53501|0 |1 is obsolete| |
--- Comment #10 from Detlef Riekenberg wine.dev@web.de --- Created attachment 55936 --> https://bugs.winehq.org/attachment.cgi?id=55936 stripped down example for g++ and wineg++
This testcase can be compiled with g++ (result works) and wineg++ (result fails)
https://bugs.winehq.org/show_bug.cgi?id=40043
--- Comment #11 from Henri Verbeet hverbeet@gmail.com --- (In reply to Detlef Riekenberg from comment #10)
This testcase can be compiled with g++ (result works) and wineg++ (result fails)
Does "-fno-short-wchar" make it any better? The underlying issue is probably that wchar_t is usually 32 bits on Linux, and 16 bits on Windows. Winegcc uses -fshort-wchar to try to work around that, but that means you can't then use things like Linux libstdc++ that assume wchar_t is 32-bit.
If you're using C++11 in particular, you're probably better of with "-fno-short-wchar" and using char16_t, u"", etc. instead of wchar_t and L"".