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

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

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