From 34b920a74f81c573c01bb854ccca0cdb4b2a1d22 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 ea5c608739..688cd338ea 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -811,13 +811,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 ); @@ -832,8 +835,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 );