KiCad PCB EDA Suite
SVG_plotter.cpp File Reference

Kicad: specialized plotter for SVG files format. More...

#include <base64.h>
#include <fctsys.h>
#include <trigo.h>
#include <eda_base_frame.h>
#include <eda_rect.h>
#include <base_struct.h>
#include <common.h>
#include <plotter.h>
#include <macros.h>
#include <kicad_string.h>
#include <cstdint>
#include <wx/mstream.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...
 

Detailed Description

Kicad: specialized plotter for SVG files format.

Definition in file SVG_plotter.cpp.

Function Documentation

◆ XmlEsc()

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 115 of file SVG_plotter.cpp.

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

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