KiCad PCB EDA Suite
SVG_plotter.cpp File Reference
#include <base64.h>
#include <eda_rect.h>
#include <eda_shape.h>
#include <string_utils.h>
#include <font/font.h>
#include <macros.h>
#include <trigo.h>
#include <cstdint>
#include <wx/mstream.h>
#include <plotters/plotters_pslike.h>

Go to the source code of this file.

Functions

static wxString XmlEsc (const wxString &aStr, bool isAttribute=false)
 Translates '<' to "&lt;", '>' to "&gt;" and so on, according to the spec: http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping May be moved to a library if needed generally, but not expecting that. More...
 

Function Documentation

◆ XmlEsc()

static wxString XmlEsc ( const wxString &  aStr,
bool  isAttribute = false 
)
static

Translates '<' to "&lt;", '>' to "&gt;" and so on, according to the spec: http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping May be moved to a library if needed generally, but not expecting that.

Definition at line 113 of file SVG_plotter.cpp.

114{
115 wxString escaped;
116
117 escaped.reserve( aStr.length() );
118
119 for( wxString::const_iterator it = aStr.begin(); it != aStr.end(); ++it )
120 {
121 const wxChar c = *it;
122
123 switch( c )
124 {
125 case wxS( '<' ):
126 escaped.append( wxS( "&lt;" ) );
127 break;
128 case wxS( '>' ):
129 escaped.append( wxS( "&gt;" ) );
130 break;
131 case wxS( '&' ):
132 escaped.append( wxS( "&amp;" ) );
133 break;
134 case wxS( '\r' ):
135 escaped.append( wxS( "&#xD;" ) );
136 break;
137 default:
138 if( isAttribute )
139 {
140 switch( c )
141 {
142 case wxS( '"' ):
143 escaped.append( wxS( "&quot;" ) );
144 break;
145 case wxS( '\t' ):
146 escaped.append( wxS( "&#x9;" ) );
147 break;
148 case wxS( '\n' ):
149 escaped.append( wxS( "&#xA;" ));
150 break;
151 default:
152 escaped.append(c);
153 }
154 }
155 else
156 escaped.append(c);
157 }
158 }
159
160 return escaped;
161}

Referenced by SVG_PLOTTER::StartPlot(), and SVG_PLOTTER::Text().