ToStdString does not work in C locale
This commit is contained in:
Seth Hillbrand
2025-09-20 13:27:16 -07:00
parent 7003c0639e
commit bbf3516611
2 changed files with 6 additions and 3 deletions
+6 -1
View File
@@ -43,6 +43,7 @@
#include <trace_helpers.h>
#include <trigo.h>
#include <string_utils.h>
#include <core/utf8.h>
#include <markup_parser.h>
#include <fmt/format.h>
#include <fmt/chrono.h>
@@ -1965,7 +1966,11 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos,
bool textMirrored = aSize.x < 0;
// Parse the text for markup
MARKUP::MARKUP_PARSER markupParser( text.ToStdString() );
// IMPORTANT: Use explicit UTF-8 encoding. wxString::ToStdString() is locale-dependent
// and under C/POSIX locale can drop or mangle non-ASCII, leading to missing CMaps.
// The markup parser expects UTF-8 bytes.
UTF8 utf8Text( text );
MARKUP::MARKUP_PARSER markupParser( utf8Text.substr() );
std::unique_ptr<MARKUP::NODE> markupTree( markupParser.Parse() );
if( !markupTree )