Don't end converting prematurely on encountering consecutive NULs.

Don't stop converting subsequent chunks just because the length of one of them
was 0: this can happen if the first character of a string is a NUL or if there
are two (or more) NULs in it later.

Simply remove the check for this and continue as usual even in this case.

Also add a unit test verifying that we do translate NULs in input into NULs in
output.

Closes #16620.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78021 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-10-14 19:36:46 +00:00
parent c66c12aa63
commit f99ff49e29
2 changed files with 4 additions and 6 deletions

View File

@ -232,12 +232,6 @@ wxMBConv::ToWChar(wchar_t *dst, size_t dstLen,
if ( !srcEnd )
dstWritten++;
if ( !lenChunk )
{
// nothing left in the input string, conversion succeeded
break;
}
if ( dst )
{
if ( dstWritten > dstLen )

View File

@ -291,6 +291,10 @@ void UnicodeTestCase::ConversionWithNULs()
CPPUNIT_ASSERT( memcmp(theLocalBuffer.data(), L"The\0String", 11 * sizeof(wchar_t)) == 0 );
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
const char *null4buff = "\0\0\0\0";
wxString null4str(null4buff, 4);
CPPUNIT_ASSERT_EQUAL( 4, null4str.length() );
}
void UnicodeTestCase::ConversionUTF7()