http://bugs.winehq.org/show_bug.cgi?id=32582
Bug #: 32582 Summary: WideCharToMultiByte: incorrectly handling of user specified DBCS "default character" Product: Wine Version: 1.5.20 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 AssignedTo: wine-bugs@winehq.org ReportedBy: thtfpcuser@126.com Classification: Unclassified
for function WideCharToMultiByte,
when there are unmapped uncode characters in target codepage,
and the user specified lpDefaultChar is DBCS character,
the default characters occured in conversion result is incorrect.
the problem is in this function:
wctomb.c
/* slow version of wcstombs_dbcs that handles the various flags */ static int wcstombs_dbcs_slow( const struct dbcs_table *table, int flags, const WCHAR *src, unsigned int srclen, char *dst, unsigned int dstlen, const char *defchar, int *used ) { const unsigned short * const uni2cp_low = table->uni2cp_low; const unsigned short * const uni2cp_high = table->uni2cp_high; WCHAR defchar_value = table->info.def_char; WCHAR composed; int len, tmp; if (defchar) defchar_value = defchar[1] ? ((defchar[0] << 8) | defchar[1]) : defchar[0];
defchar[0] has only 8 bits. left shifts 8 bits, its value is lost.
http://bugs.winehq.org/show_bug.cgi?id=32582
thtfpcuser thtfpcuser@126.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |winelib Severity|normal |minor
--- Comment #1 from thtfpcuser thtfpcuser@126.com 2012-12-28 21:34:54 CST --- it is different from the problem WideCharToMultiByte: incorrect conversion of "default character".
http://bugs.winehq.org/show_bug.cgi?id=32582
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords|winelib |
https://bugs.winehq.org/show_bug.cgi?id=32582
--- Comment #2 from Austin English austinenglish@gmail.com --- Is this still an issue in current (1.7.35 or newer) wine? If so, please attach terminal output.
https://bugs.winehq.org/show_bug.cgi?id=32582
--- Comment #3 from Nikolay Sivov bunglehead@gmail.com --- thtfpcuser, could you please provide input string and target codepage number you're using so we can turn this into a test case?
https://bugs.winehq.org/show_bug.cgi?id=32582
--- Comment #4 from thtfpcuser thtfpcuser@126.com --- Created attachment 52222 --> https://bugs.winehq.org/attachment.cgi?id=52222 test code reproduce the bug
this is the source code that reproduce the bug.
https://bugs.winehq.org/show_bug.cgi?id=32582
--- Comment #5 from thtfpcuser thtfpcuser@126.com --- Created attachment 52223 --> https://bugs.winehq.org/attachment.cgi?id=52223 test code output result.
this is the output result of test code, which run on wine 1.7.50.
https://bugs.winehq.org/show_bug.cgi?id=32582
--- Comment #6 from thtfpcuser thtfpcuser@126.com --- (In reply to Nikolay Sivov from comment #3)
thtfpcuser, could you please provide input string and target codepage number you're using so we can turn this into a test case?
hi Nikolay, i have attached the test code and terminal output.
https://bugs.winehq.org/show_bug.cgi?id=32582
--- Comment #7 from thtfpcuser thtfpcuser@126.com --- (In reply to Austin English from comment #2)
Is this still an issue in current (1.7.35 or newer) wine? If so, please attach terminal output.
hi Austin, this is still an issue in 1.7.50 wine. i have attached test code and terminal output.
https://bugs.winehq.org/show_bug.cgi?id=32582
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
https://bugs.winehq.org/show_bug.cgi?id=32582
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Severity|minor |normal
--- Comment #8 from Nikolay Sivov bunglehead@gmail.com --- I can confirm that test fails on Wine and works on Win8.1. I just submitted a possible fix for that https://www.winehq.org/pipermail/wine-patches/2015-September/142258.html.
https://bugs.winehq.org/show_bug.cgi?id=32582
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |a7e294c064ac443a4351d1cbe84 | |e7f52e0775d6f Status|NEW |RESOLVED Resolution|--- |FIXED
--- Comment #9 from Nikolay Sivov bunglehead@gmail.com --- Alexandre committed a better version, should be fixed now with a7e294c064ac443a4351d1cbe84e7f52e0775d6f.
https://bugs.winehq.org/show_bug.cgi?id=32582
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #10 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 1.7.52.