From 00f93db2ffdaf9579985267fe53d5de73cf644af Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 23 Jan 2023 15:21:05 -0800 Subject: [PATCH] Convert wide chars before reading model The PEGTL parser used by KiCad for SPICE models only handles ASCII characters. Despite the docs stating that you can, in theory, parse a UTF-8 character by reading the base string, in pratice this does not work as the UTF-8 string is represented by unsigned chars and the PEGTL string is based on signed char. To work around this, we need to convert micro and mu to the ASCII 'u' equivalent Fixes https://gitlab.com/kicad/code/kicad/issues/13642 --- eeschema/sim/sim_model.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index e57af8de13..22890407dc 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -1107,6 +1107,11 @@ bool SIM_MODEL::InferSimModel( T_symbol& aSymbol, std::vector* aFields, auto convertNotation = [&]( const wxString& units ) -> wxString { + /// KiCad Spice PEGTL only handles ASCII + /// Although these two look the same, they are U+03BC and U+00B5 + if( units == wxS( "µ" ) || units == wxS( "μ" ) ) + return wxS( "u" ); + if( aNotation == SIM_VALUE_GRAMMAR::NOTATION::SPICE ) { if( units == wxT( "M" ) )