Fix handling of "%s" in vararg functions in some UTF-8 builds

When wxUSE_UNICODE_UTF8 is set to 1, strings use UTF-8 and are still
char strings and not wchar_t ones, but when using wx own implementation
of vsnprintf(), "%s" expected a wide string and not a normal one.

Fix this at wxPrintfFormatConverterUtf8 level.

Closes #26236.
This commit is contained in:
Randalphwa
2026-02-23 14:43:51 -08:00
committed by Vadim Zeitlin
parent 5d0281ebd0
commit c90aaa3d09

View File

@@ -478,7 +478,14 @@ class wxPrintfFormatConverterUtf8 : public wxFormatConverterBase<char>
CharType& outConv, SizeModifier& outSize) override
{
outConv = 's';
#if wxUSE_WXVSNPRINTFA
// When using wx's own vsnprintf implementation, plain %s is
// interpreted as wchar_t*. We need %hs to indicate char* args,
// which is what we actually pass in UTF-8 builds.
outSize = Size_Short;
#else
outSize = Size_Default;
#endif
}
virtual void HandleChar(CharType WXUNUSED(conv),