Helper class for setting up rules for string escaping.
sealed class
|
StringEscape
|
Common escaping rules for backslash characters using two backslash characters.
public
static
readonly
field
|
BackslashRepeat
|
||
type
|
StringEscape
|
Remarks:
[\] (0x5C) => [\\] (0x5C, 0x5C)
Common escaping rules for double quote characters using a backslash.
public
static
readonly
field
|
DoubleQuotesBackslash
|
||
type
|
StringEscape
|
Remarks:
["] (0x22) => [\"] (0x5C, 0x22)
Common escaping rules for double quote characters using a two double quote characters.
public
static
readonly
field
|
DoubleQuotesRepeat
|
||
type
|
StringEscape
|
Remarks:
["] (0x22) => [""] (0x22, 0x22)
Common escaping rules capturing strings in a single line, enclosed by double quotes.
public
static
readonly
field
|
LineDoubleQuote
|
||
type
|
StringEscape
|
Remarks:
["] (0x22) => [""] (0x22, 0x22) [ ] (0x09) => [\t] (0x5C, 0x74) [ ] (0x0A) => [\n] (0x5C, 0x6E) [ ] (0x0D) => [\r] (0x5C, 0x72) [\] (0x5C) => [\\] (0x5C, 0x5C)
Common escaping rules capturing strings in a single line, enclosed by single quotes.
public
static
readonly
field
|
LineSingleQuote
|
||
type
|
StringEscape
|
Remarks:
['] (0x22) => [\'] (0x5C, 0x22) [ ] (0x09) => [\t] (0x5C, 0x74) [ ] (0x0A) => [\n] (0x5C, 0x6E) [ ] (0x0D) => [\r] (0x5C, 0x72) [\] (0x5C) => [\\] (0x5C, 0x5C)
No string escaping.
public
static
readonly
field
|
None
|
||
type
|
StringEscape
|
Common escaping rules for single quote characters using a backslash.
public
static
readonly
field
|
SingleQuotesBackslash
|
||
type
|
StringEscape
|
Remarks:
['] (0x22) => [\'] (0x5C, 0x22)
Common escaping rules for single quote characters using a two single quote characters.
public
static
readonly
field
|
SingleQuotesRepeat
|
||
type
|
StringEscape
|
Remarks:
['] (0x22) => [''] (0x22, 0x22)
Common escaping rules for spacing characters using a backslash.
public
static
readonly
field
|
SpacingBackslash
|
||
type
|
StringEscape
|
Remarks:
[ ] (0x09) => [\t] (0x5C, 0x74) [ ] (0x0A) => [\n] (0x5C, 0x6E) [ ] (0x0D) => [\r] (0x5C, 0x72)
Adds all escaping rules of the given StringEscape object to this object.
public
method
|
Add
(StringEscape other)
|
||
type
|
StringEscape
|
||
params
|
other
|
[not-null]
|
The other object. |
returns
|
|
The resulting StringEscape object. |
Adds the given plain/escaped pair to this string escape object.
public
method
|
Add
(string plain,
string escaped)
|
||
type
|
StringEscape
|
||
params
|
plain
|
[not-empty]
|
The plain token. |
escaped
|
[not-empty]
|
The escaped token. | |
returns
|
|
The resulting StringEscape object. |
Checks if this StringEscape already contains a rule for escaping the given plain resp. escaped token.
public
method
|
Contains
(string plain,
string escaped = null)
|
||
type
|
bool
|
||
params
|
plain
|
The
plain
token
or
null . |
|
escaped
|
The
escaped
token
or
null . |
||
returns
|
true
if
this
StringEscape
object
contains
a
matching
escape
rule
(see
remarks),
false
if
not.
|
Remarks:
If
both
plain
and
escaped
are
null
,
the
method
returns
null
.
If
both
are
non-null
,
an
escape
rule
is
searched
that
replaces
plain
with
escaped.
If
only
plain
resp.
escaped
is
null
,
an
escape
rule
is
searched
that
replaces
plain
with
any
token
resp.
replaces
any
token
with
escaped.
Escapes the given plain string by applying all escaping rules.
public
method
|
Escape
(string plain)
|
||
type
|
string
|
||
params
|
plain
|
The plain string. | |
returns
|
The escaped string. |
Creates a new instance of StringEscape that replaces the given plain token with the specified escape token.
public
static
method
|
New
(string plain,
string escaped)
|
||
type
|
StringEscape
|
||
params
|
plain
|
[not-empty]
|
The plain token. |
escaped
|
[not-empty]
|
The escaped token. | |
returns
|
|
The StringEscape object. |
Remarks:
Additional plain/escaped pairs can be added by calling Add and Add on the returned StringEscape object.
Unescapes the given escaped string by reversing all escaping rules.
public
method
|
Unescape
(string escaped)
|
||
type
|
string
|
||
params
|
escaped
|
The escaped string. | |
returns
|
The plain string. |