From 00d6e4f7dd828f42cff3b257f1f3a0d312c1defc Mon Sep 17 00:00:00 2001 From: millanzarreta Date: Thu, 25 Sep 2025 21:12:32 +0200 Subject: [PATCH 1/2] [HTML] Ensure safe global locale fallback setup --- engine/report/report_html_sim.cpp | 34 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/engine/report/report_html_sim.cpp b/engine/report/report_html_sim.cpp index b1c0bd7520d..8ccd53b5cf0 100644 --- a/engine/report/report_html_sim.cpp +++ b/engine/report/report_html_sim.cpp @@ -1164,20 +1164,34 @@ void print_profilesets( std::ostream& out, const profileset::profilesets_t& prof out << ""; } -/* Main function building the html document and calling subfunctions - */ -void print_html_( report::sc_html_stream& os, sim_t& sim ) -{ +void set_global_locale( ) { // Set global locale to en-US for consistent number formatting - try + for (const auto& name : { - std::locale::global( std::locale( "en_US.UTF-8" ) ); - } - catch ( const std::runtime_error& ) + "en_US.UTF-8", + "en_US.utf8", + "English_United States.65001", + "en_US", + "en-US", + "English_United States.1252", + "C" + }) { - // backup spelling for CI - std::locale::global( std::locale( "en_US.utf8" ) ); + try { + std::locale::global(std::locale(name)); + return; + } catch (const std::runtime_error&) + { } } + std::locale::global(std::locale::classic()); +} + +/* Main function building the html document and calling subfunctions + */ +void print_html_( report::sc_html_stream& os, sim_t& sim ) +{ + // Set global locale formatting + set_global_locale(); // Set floating point formatting os.precision( sim.report_precision ); From 4bad0ae364131bac0f94d4ca009d36d8b4fd03e1 Mon Sep 17 00:00:00 2001 From: millanzarreta Date: Thu, 25 Sep 2025 21:23:22 +0200 Subject: [PATCH 2/2] [HTML] Ensure safe global locale fallback setup: style adjustments --- engine/report/report_html_sim.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/engine/report/report_html_sim.cpp b/engine/report/report_html_sim.cpp index 8ccd53b5cf0..b346fff7a1d 100644 --- a/engine/report/report_html_sim.cpp +++ b/engine/report/report_html_sim.cpp @@ -1164,9 +1164,10 @@ void print_profilesets( std::ostream& out, const profileset::profilesets_t& prof out << ""; } -void set_global_locale( ) { +void set_global_locale() +{ // Set global locale to en-US for consistent number formatting - for (const auto& name : + for ( const auto& name : { "en_US.UTF-8", "en_US.utf8", @@ -1175,15 +1176,17 @@ void set_global_locale( ) { "en-US", "English_United States.1252", "C" - }) + } ) { - try { - std::locale::global(std::locale(name)); + try + { + std::locale::global( std::locale( name ) ); return; - } catch (const std::runtime_error&) + } + catch ( const std::runtime_error& ) { } } - std::locale::global(std::locale::classic()); + std::locale::global( std::locale::classic() ); } /* Main function building the html document and calling subfunctions