KiCad PCB EDA Suite
common_plotSVG_functions.cpp File Reference
#include <fctsys.h>
#include <trigo.h>
#include <wxstruct.h>
#include <class_eda_rect.h>
#include <base_struct.h>
#include <common.h>
#include <class_plotter.h>
#include <macros.h>
#include <kicad_string.h>

Go to the source code of this file.

Functions

static wxString XmlEsc (const wxString &aStr, bool isAttribute=false)
 Function XmlEsc 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

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

Function XmlEsc 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 111 of file common_plotSVG_functions.cpp.

Referenced by SVG_PLOTTER::StartPlot().

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