diff --git a/common/lib_id.cpp b/common/lib_id.cpp index 388f0cbe93..f92d3ce314 100644 --- a/common/lib_id.cpp +++ b/common/lib_id.cpp @@ -403,18 +403,19 @@ const unsigned schIllegalChars[] = { BASE_ILLEGAL_CHARS, ' ' }; const unsigned pcbIllegalChars[] = { BASE_ILLEGAL_CHARS, 0 }; #define ILL_CHAR_SIZE (sizeof(schIllegalChars) / sizeof(int)) -bool LIB_ID::isLegalChar( unsigned aChar, LIB_ID_TYPE aType ) +bool LIB_ID::isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType ) { const unsigned (&illegalChars)[ILL_CHAR_SIZE] = aType == ID_SCH ? schIllegalChars : pcbIllegalChars; for( const unsigned ch : illegalChars ) { - if( ch == aChar ) + if( ch == aUniChar ) return false; } - if( !wxIsascii( aChar ) ) + // Test for "printable" code (aUniChar is a unicode (32 bits) char, not a ASCII value ) + if( aUniChar < ' ' ) return false; return true; diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 5bf514a734..a451605f7b 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -137,7 +137,6 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer, { typedef std::map candidate_map_t; candidate_map_t candidate_map; - // Remember the list of components is sorted by part name. // So a search in libraries is made only once by group LIB_ALIAS* case_sensitive_match = nullptr; @@ -380,15 +379,17 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( // Test whether there is a conflict or if the symbol can only be found in the cache. if( ( ( cache_match && lib_match - && !cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) ) - || (!cache_match && lib_match ) ) - && !LIB_ID::HasIllegalChars( part_id.GetLibItemName(), LIB_ID::ID_SCH ) ) + && !cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) ) + || (!cache_match && lib_match ) ) + && !LIB_ID::HasIllegalChars( part_id.GetLibItemName(), LIB_ID::ID_SCH ) ) + { continue; + } // Fix illegal LIB_ID name characters. wxString new_name = LIB_ID::FixIllegalChars( part_id.GetLibItemName(), LIB_ID::ID_SCH ); - // Differentiate symbol name in the resue library by appending the symbol library + // Differentiate symbol name in the rescue library by appending the symbol library // table nickname to the symbol name to prevent name clashes in the rescue library. wxString libNickname = GetRescueLibraryFileName().GetName(); diff --git a/include/lib_id.h b/include/lib_id.h index f4c2277f62..3b17789e13 100644 --- a/include/lib_id.h +++ b/include/lib_id.h @@ -236,8 +236,11 @@ public: #endif protected: - ///> Tests whether a character is a legal LIB_ID character - static bool isLegalChar( unsigned aChar, LIB_ID_TYPE aType ); + /** Tests whether a unicode character is a legal LIB_ID character + * note: aUniChar is expected to be a unicode 32 bits char, not a UTF8 char, that use + * a variable lenght coding value + */ + static bool isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType ); UTF8 nickname; ///< The nickname of the library or empty. UTF8 item_name; ///< The name of the entry in the logical library.