EasyEDA Std: Handle HTML escape characters in text.
This commit is contained in:
parent
d0b26ae600
commit
f48a248db4
|
@ -545,7 +545,37 @@ wxString UnescapeHTML( const wxString& aString )
|
|||
converted.Replace( wxS( "<" ), wxS( "<" ) );
|
||||
converted.Replace( wxS( ">" ), wxS( ">" ) );
|
||||
|
||||
return converted;
|
||||
// Yes, &#123; is going to give unexpected results.
|
||||
|
||||
wxString result;
|
||||
|
||||
wxRegEx regex( "&#(\\d*);" );
|
||||
|
||||
size_t start = 0;
|
||||
size_t len = 0;
|
||||
|
||||
wxString str = aString;
|
||||
|
||||
while( regex.Matches( str ) )
|
||||
{
|
||||
std::vector<wxString> matches;
|
||||
regex.GetMatch( &start, &len );
|
||||
|
||||
result << str.Left( start );
|
||||
|
||||
unsigned long codeVal = 0;
|
||||
wxString code = regex.GetMatch( str, 1 );
|
||||
code.ToCULong( &codeVal );
|
||||
|
||||
if( codeVal != 0 )
|
||||
result << wxUniChar( codeVal );
|
||||
|
||||
str = str.Mid( start + len );
|
||||
}
|
||||
|
||||
result << str;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -810,7 +810,10 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
|
|||
wxString fontSize = arr[7];
|
||||
wxString baselineAlign = arr[10];
|
||||
wxString textStr = arr[12];
|
||||
|
||||
textStr.Replace( wxS( "\\n" ), wxS( "\n" ) );
|
||||
textStr = UnescapeHTML( textStr );
|
||||
|
||||
wxString halignStr = arr[14]; // Empty, start, middle, end, inherit
|
||||
|
||||
bool added = false;
|
||||
|
@ -1311,7 +1314,10 @@ void SCH_EASYEDA_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRoot
|
|||
wxString fontSize = arr[7];
|
||||
wxString baselineAlign = arr[10];
|
||||
wxString textStr = arr[12];
|
||||
|
||||
textStr.Replace( wxS( "\\n" ), wxS( "\n" ) );
|
||||
textStr = UnescapeHTML( textStr );
|
||||
|
||||
wxString halignStr = arr[14]; // Empty, start, middle, end, inherit
|
||||
|
||||
std::unique_ptr<SCH_TEXT> textItem =
|
||||
|
|
|
@ -778,7 +778,7 @@ void PCB_EASYEDA_PARSER::ParseToBoardItemContainer(
|
|||
double height = ConvertSize( arr[9] ) * 0.8;
|
||||
text->SetTextSize( VECTOR2I( height, height ) );
|
||||
|
||||
text->SetText( arr[10] );
|
||||
text->SetText( UnescapeHTML( arr[10] ) );
|
||||
|
||||
//arr[11] // Geometry data
|
||||
|
||||
|
|
Loading…
Reference in New Issue