Fix initialization of SingleCharBuffer and Utf16CharBuffer data

Don't do it at all in the ctor, initializing just the first element of
the array is useless as it's overwritten by EncodeChar() anyhow, so just
leave the task of NUL-terminating the data to this function as well.

It might be even better to just have a ctor taking wxUniChar in these
classes instead and make EncodeChar() a trivial wrapper around it, but
for now just apply the minimal fix to repair the test breakage after the
last commit.

See https://github.com/wxWidgets/wxWidgets/pull/467#issuecomment-310384946
This commit is contained in:
Vadim Zeitlin
2017-06-22 15:51:49 +02:00
parent 4d3aaafc86
commit bfb893170e
2 changed files with 5 additions and 14 deletions

View File

@@ -38,11 +38,13 @@ wxStringOperationsWchar::Utf16CharBuffer wxStringOperationsWchar::EncodeChar(con
{
buf.data[0] = (wchar_t)ch.HighSurrogate();
buf.data[1] = (wchar_t)ch.LowSurrogate();
buf.data[2] = L'\0';
}
else
{
// Assume ch is a BMP character
buf.data[0] = (wchar_t)ch;
buf.data[1] = L'\0';
}
return buf;
}