← Back to team overview

kicad-developers team mailing list archive

Eeshema wrong saves the components with unicode names.

 

Hello!

Sorry for my english.
There is a problem. In the file "eeschema/sch_component.cpp" in the
function "bool SCH_COMPONENT::Save( FILE* f ) const" there is this code:
...

if( !m_ChipName.IsEmpty() )
    {
        strncpy( Name2, TO_UTF8( m_ChipName ), sizeof( Name2 ) );
        for( ii = 0; ii < (int) strlen( Name2 ); ii++ )
#if defined(KICAD_GOST)     // <- This place is a little strange.

            if( Name2[ii] == ' ' )
#else

            if( Name2[ii] <= ' ' )   // <- This string execute by
default
#endif

                Name2[ii] = '~';
    }
    else
...

How I understand, here is going the replacement the symbol ' ' on '~'.
Here is two problems:
1) Name2 contains a unicode text. That is, "Name2[ii] <= ' ' " is not
completety correct, but acceptable.
2) Unicode characters have code higher 0x7F. But Name2[] is signed char.
That is unicode character in Name2[] have code lower 0. Name2[ii] <= ' '
is true always for unicode characters and their are replaced on '~'.
Solving the problem might be:   if( (unsigned char)Name2[ii] <= ' ' ).

IfoR.
-- 
This message was sent from Launchpad by
IfoR (https://launchpad.net/~smtp-iforand)
using the "Contact this team" link on the KiCad Developers team page
(https://launchpad.net/~kicad-developers).
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople


Follow ups