Fix a unit test in UTF-8 build using UTF-8 strings only
Avoid the optimized mb_str() available in this build returning directly a "char*" as it doesn't preserve the length of the string if it contains NULs. Use mb_str(wxMBConv) overload instead which always returns the buffer of the correct length. Arguably, this is a problem of wxString API and maybe this optimized mb_str() overload shouldn't be provided at all. OTOH the main reason for wxUSE_UTF8_LOCALE_ONLY existence is optimization, so it seems a pity to deliberately make the code less efficient when using it.
This commit is contained in:
parent
6d3530a653
commit
9c1964ee1d
@ -269,7 +269,7 @@ void UnicodeTestCase::ConversionWithNULs()
|
||||
static const size_t lenNulString = 10;
|
||||
|
||||
wxString szTheString(L"The\0String", wxConvLibc, lenNulString);
|
||||
wxCharBuffer theBuffer = szTheString.mb_str();
|
||||
wxCharBuffer theBuffer = szTheString.mb_str(wxConvLibc);
|
||||
|
||||
CPPUNIT_ASSERT( memcmp(theBuffer.data(), "The\0String",
|
||||
lenNulString + 1) == 0 );
|
||||
|
Loading…
Reference in New Issue
Block a user