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.