MCPcopy Create free account
hub / github.com/KiCad/kicad-source-mirror / EscapeString

Function EscapeString

common/string_utils.cpp:187–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185
186
187wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
188{
189 wxString converted;
190 std::vector<bool> braceStack; // true == formatting construct
191
192 converted.reserve( aSource.length() );
193
194 for( wxUniChar c: aSource )
195 {
196 if( aContext == CTX_NETNAME )
197 {
198 if( c == '/' )
199 converted += wxT( "{slash}" );
200 else if( c == '\n' || c == '\r' )
201 converted += wxEmptyString; // drop
202 else
203 converted += c;
204 }
205 else if( aContext == CTX_LIBID || aContext == CTX_LEGACY_LIBID )
206 {
207 // We no longer escape '/' in LIB_IDs, but we used to
208 if( c == '/' && aContext == CTX_LEGACY_LIBID )
209 converted += wxT( "{slash}" );
210 else if( c == '\\' )
211 converted += wxT( "{backslash}" );
212 else if( c == '<' )
213 converted += wxT( "{lt}" );
214 else if( c == '>' )
215 converted += wxT( "{gt}" );
216 else if( c == ':' )
217 converted += wxT( "{colon}" );
218 else if( c == '\"' )
219 converted += wxT( "{dblquote}" );
220 else if( c == '\n' || c == '\r' )
221 converted += wxEmptyString; // drop
222 else
223 converted += c;
224 }
225 else if( aContext == CTX_IPC )
226 {
227 if( c == '/' )
228 converted += wxT( "{slash}" );
229 else if( c == ',' )
230 converted += wxT( "{comma}" );
231 else if( c == '\"' )
232 converted += wxT( "{dblquote}" );
233 else
234 converted += c;
235 }
236 else if( aContext == CTX_QUOTED_STR )
237 {
238 if( c == '\"' )
239 converted += wxT( "{dblquote}" );
240 else
241 converted += c;
242 }
243 else if( aContext == CTX_JS_STR )
244 {

Callers 15

SetValueMethod · 0.85
StringToValueMethod · 0.85
ParseBusGroupMethod · 0.85
AltiumToKiCadLibIDFunction · 0.85
ToKiCadLibIDMethod · 0.85
generateLibNameMethod · 0.85
endPlotEmitResourcesMethod · 0.85
escapeLibIdMethod · 0.85
ClickOnLibListMethod · 0.85
ClickOnSymbolListMethod · 0.85
FindRescuesMethod · 0.85

Calls 1

lengthMethod · 0.45

Tested by 1

onRenameSelectedNetMethod · 0.68