StringEscape

Description

[ShutdownSurvive]
sealed class Tinman.Core.Formatting.StringEscape

Helper class for setting up rules for string escaping.

Public / Constants

Line​Single​Quote


public static readonly attribute LineSingleQuote → (StringEscape)

Common escaping rules capturing strings in a single line, enclosed by single quotes.

['] (0x22) => [\'] (0x5C, 0x22)
[ ] (0x09) => [\t] (0x5C, 0x74)
[ ] (0x0A) => [\n] (0x5C, 0x6E)
[ ] (0x0D) => [\r] (0x5C, 0x72)
[\] (0x5C) => [\\] (0x5C, 0x5C)

None


public static readonly attribute None → (StringEscape)

No string escaping.

Public / Methods

Add

2 overloads


public method Add1 → (1)

rule in : IStringOp

[not-null]
The reversible string operation that represents the string escaping rule to add.

returns → StringEscape

this

Adds the given string escaping rule.


public method Add2 → (3)

plain in : string

[not-empty]
The plain token.

escaped in : string

[not-empty]
The escaped token.

direction opt : int32 = 0

The escape processing direction:
= 0 : both directions
> 0 : plain in to escaped in
< 0 : escaped in to plain in

returns → StringEscape

The resulting StringEscape object.

Adds the given plain/escaped pair to this string escape object.

Escape


public method Escape → (1)

plain in : string

The plain string.

returns → string

The escaped string.

Escapes the given plain string by applying all escaping rules.

Unescape


public method Unescape → (1)

escaped in : string

The escaped string.

returns → string

The plain string.

Unescapes the given escaped string by reversing all escaping rules.

Public / Attributes

Is​Reversible


[Constant]
public attribute IsReversible → (get)

value : bool

true if all string escaping rules are reversible,
false if some are irreversible.

Checks if all string escaping rules are reversible.