From f84bd0d83692844fe2fdc540f071fb28d733ecab Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 30 Aug 2018 13:05:54 -0700 Subject: [PATCH] pcbnew: Fix Eagle UTF8 import error Implicit convertion from wxString to std::string will use narrow strings and drop UTF-8. Fixes: lp:1789311 * https://bugs.launchpad.net/kicad/+bug/1789311 --- pcbnew/eagle_plugin.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 602e49e021..22f551f2ba 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -816,13 +816,16 @@ void EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLib, const wxString* aLibName ) { m_xpath->push( "package", "name" ); - const wxString& pack_ref = package->GetAttribute( "name" ); - std::string pack_name( pack_ref ); - ReplaceIllegalFileNameChars( &pack_name, '_' ); + wxString pack_ref = package->GetAttribute( "name" ); + ReplaceIllegalFileNameChars( pack_ref, '_' ); + std::string pack_name = Convert( pack_ref ); + + if(pack_name.length() == 0 ) + printf("Empty!\n"); m_xpath->Value( pack_name.c_str() ); - wxString key = aLibName ? makeKey( *aLibName, pack_name ) : wxString( pack_name ); + wxString key = aLibName ? makeKey( *aLibName, pack_ref ) : pack_ref; MODULE* m = makeModule( package, pack_name ); @@ -837,8 +840,9 @@ void EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLib, const wxString* aLibName ) wxString pkg = FROM_UTF8( pack_name.c_str() ); wxString emsg = wxString::Format( - _( " name: \"%s\" duplicated in eagle : \"%s\"" ), + _( " name: \"%s\" : %s duplicated in eagle : \"%s\"" ), GetChars( pkg ), + GetChars( key ), GetChars( lib ) ); THROW_IO_ERROR( emsg );