spice netlist generation: use utf8 format.
Using basic conversion from unicode to 8bits strings can break non ASCII7 strings Fixes #8192 https://gitlab.com/kicad/code/kicad/issues/8192
This commit is contained in:
parent
4f191ce2c7
commit
5bfda7f1f0
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 1992-2013 jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -87,7 +87,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
|
|||
if( !ProcessNetlist( aCtl ) )
|
||||
return false;
|
||||
|
||||
aFormatter->Print( 0, ".title %s\n", (const char*) m_title.c_str() );
|
||||
aFormatter->Print( 0, ".title %s\n", TO_UTF8( m_title ) );
|
||||
|
||||
// Write .include directives
|
||||
for( const auto& lib : m_libraries )
|
||||
|
@ -108,7 +108,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
|
|||
else
|
||||
full_path = lib; // just use the unaltered path
|
||||
|
||||
aFormatter->Print( 0, ".include \"%s\"\n", (const char*) full_path.c_str() );
|
||||
aFormatter->Print( 0, ".include \"%s\"\n", TO_UTF8( full_path ) );
|
||||
}
|
||||
|
||||
unsigned int NC_counter = 1;
|
||||
|
@ -119,7 +119,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
|
|||
continue;
|
||||
|
||||
wxString device = GetSpiceDevice( item.m_refName );
|
||||
aFormatter->Print( 0, "%s ", (const char*) device.c_str() );
|
||||
aFormatter->Print( 0, "%s ", TO_UTF8( device ) );
|
||||
|
||||
size_t pspiceNodes = item.m_pinSequence.empty() ? item.m_pins.size() : item.m_pinSequence.size();
|
||||
|
||||
|
@ -159,7 +159,7 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl
|
|||
}
|
||||
}
|
||||
|
||||
aFormatter->Print( 0, "%s\n", (const char*) item.m_model.c_str() );
|
||||
aFormatter->Print( 0, "%s\n", TO_UTF8( item.m_model ) );
|
||||
}
|
||||
|
||||
// Print out all directives found in the text fields on the schematics
|
||||
|
@ -464,7 +464,7 @@ void NETLIST_EXPORTER_PSPICE::writeDirectives( OUTPUTFORMATTER* aFormatter, unsi
|
|||
{
|
||||
for( auto& dir : m_directives )
|
||||
{
|
||||
aFormatter->Print( 0, "%s\n", (const char*) dir.c_str() );
|
||||
aFormatter->Print( 0, "%s\n", TO_UTF8( dir ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* Copyright (C) 2016 CERN
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 3
|
||||
|
@ -24,6 +26,7 @@
|
|||
|
||||
#include "netlist_exporter_pspice_sim.h"
|
||||
#include <kicad_string.h>
|
||||
#include <macros.h> // for TO_UTF8 def
|
||||
#include <wx/regex.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
|
@ -33,8 +36,8 @@ wxString NETLIST_EXPORTER_PSPICE_SIM::ComponentToVector(
|
|||
wxString res;
|
||||
|
||||
// Some of the flags should exclude mutually
|
||||
assert( ( ( aType & SPT_VOLTAGE ) == 0 ) != ( ( aType & SPT_CURRENT ) == 0 ) );
|
||||
assert( ( ( aType & SPT_AC_PHASE ) == 0 ) || ( ( aType & SPT_AC_MAG ) == 0 ) );
|
||||
wxASSERT( ( ( aType & SPT_VOLTAGE ) == 0 ) != ( ( aType & SPT_CURRENT ) == 0 ) );
|
||||
wxASSERT( ( ( aType & SPT_AC_PHASE ) == 0 ) || ( ( aType & SPT_AC_MAG ) == 0 ) );
|
||||
|
||||
if( aType & SPT_VOLTAGE )
|
||||
{
|
||||
|
@ -237,8 +240,7 @@ void NETLIST_EXPORTER_PSPICE_SIM::writeDirectives( OUTPUTFORMATTER* aFormatter,
|
|||
|
||||
/// @todo is it required to switch to lowercase
|
||||
aFormatter->Print( 0, ".save %s\n",
|
||||
(const char*) ComponentToVector( item.m_refName, SPT_CURRENT, current )
|
||||
.c_str() );
|
||||
TO_UTF8( ComponentToVector( item.m_refName, SPT_CURRENT, current ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +254,7 @@ void NETLIST_EXPORTER_PSPICE_SIM::writeDirectives( OUTPUTFORMATTER* aFormatter,
|
|||
if( netname == "V(0)" || netname == "V(GND)" )
|
||||
continue;
|
||||
|
||||
aFormatter->Print( 0, ".save %s\n", (const char*) netname.c_str() );
|
||||
aFormatter->Print( 0, ".save %s\n", TO_UTF8( netname ) );
|
||||
}
|
||||
|
||||
if( m_simCommand.IsEmpty() )
|
||||
|
@ -266,10 +268,10 @@ void NETLIST_EXPORTER_PSPICE_SIM::writeDirectives( OUTPUTFORMATTER* aFormatter,
|
|||
for( const auto& dir : GetDirectives() )
|
||||
{
|
||||
if( !IsSimCommand( dir ) )
|
||||
aFormatter->Print( 0, "%s\n", (const char*) dir.c_str() );
|
||||
aFormatter->Print( 0, "%s\n", TO_UTF8( dir ) );
|
||||
}
|
||||
|
||||
// Finish with our custom simulation command
|
||||
aFormatter->Print( 0, "%s\n", (const char*) m_simCommand.c_str() );
|
||||
aFormatter->Print( 0, "%s\n", TO_UTF8( m_simCommand ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue