From 8c5df4b485f2f4d1e5c2b140c7c92e3a2ffd5312 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 23 Jun 2022 22:12:16 +0200 Subject: [PATCH] Use UTF-8 locale in Unicode formatting test At least under FreeBSD, vsnprintf() doesn't work with Unicode strings in non-UTF-8 locales (but just returns EILSEQ), so set such locale before using it. --- tests/strings/strings.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/strings/strings.cpp b/tests/strings/strings.cpp index 5b48f37bbc..a5acd38bba 100644 --- a/tests/strings/strings.cpp +++ b/tests/strings/strings.cpp @@ -17,6 +17,8 @@ #include "wx/wx.h" #endif // WX_PRECOMP +#include "wx/private/localeset.h" + // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- @@ -196,6 +198,10 @@ void StringTestCase::Format() void StringTestCase::FormatUnicode() { #if wxUSE_UNICODE + // At least under FreeBSD vsnprintf(), used by wxString::Format(), doesn't + // work with Unicode strings unless a UTF-8 locale is used, so set it. + wxLocaleSetter loc("C.UTF-8"); + const char *UNICODE_STR = "Iestat\xC4\xAB %i%i"; //const char *UNICODE_STR = "Iestat\xCC\x84 %i%i";