diff --git a/interface/wx/strconv.h b/interface/wx/strconv.h index 9d89c37e78..9388b49135 100644 --- a/interface/wx/strconv.h +++ b/interface/wx/strconv.h @@ -121,7 +121,7 @@ public: including the terminating @c NUL character(s). @return - The number of character written (or which would have been written + The number of characters written (or which would have been written if it were non-@NULL) to @a dst or @c wxCONV_FAILED on error. */ virtual size_t ToWChar(wchar_t* dst, size_t dstLen, const char* src, @@ -148,8 +148,13 @@ public: including the terminating @c NUL character. @return - The number of character written (or which would have been written - if it were non-@NULL) to @a dst or @c wxCONV_FAILED on error. + If @dst is non-@NULL, the number of characters actually written to + it. If @dst is @NULL, the returned value is at least equal to the + number of characters that would have been written out if it were + non-@NULL, but can be larger than it under the platforms using + UTF-16 as @c wchar_t encoding (this allows a useful optimization in + the implementation of this function for UTF-32). In any case, + @c wxCONV_FAILED is returned on conversion error. */ virtual size_t FromWChar(char* dst, size_t dstLen, const wchar_t* src, size_t srcLen = wxNO_LEN) const; diff --git a/tests/mbconv/mbconvtest.cpp b/tests/mbconv/mbconvtest.cpp index 10985fe3d5..69044cc057 100644 --- a/tests/mbconv/mbconvtest.cpp +++ b/tests/mbconv/mbconvtest.cpp @@ -1096,15 +1096,16 @@ void MBConvTestCase::TestEncoder( memcpy( inputCopy.data(), wideBuffer, (wideChars*sizeof(wchar_t)) ); inputCopy.data()[wideChars] = 0; - // calculate the output size + // calculate the output size: notice that it can be greater than the real + // size as the converter is allowed to estimate the maximal size needed + // instead of computing it precisely size_t outputWritten = converter.WC2MB ( 0, (const wchar_t*)inputCopy.data(), 0 ); - // make sure the correct output length was calculated - CPPUNIT_ASSERT_EQUAL( multiBytes, outputWritten ); + CPPUNIT_ASSERT( outputWritten >= multiBytes ); // convert the string size_t guardBytes = 8; // to make sure we're not overrunning the output buffer