KiCad PCB EDA Suite
SVG_plotter.cpp File Reference

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

#include <base64.h>
#include <eda_rect.h>
#include <eda_shape.h>
#include <string_utils.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...
 

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

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

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

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