sealed class Tinman.Core.Formatting.StringEscape

Helper class for setting up rules for string escaping.

Public / Constants


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)


public static readonly attribute None → (StringEscape)

No string escaping.

Public / Methods


2 overloads

public method Add1 → (1)

rule in : IStringOp

The reversible string operation that represents the string escaping rule to add.

returns → StringEscape


Adds the given string escaping rule.

public method Add2 → (3)

plain in : string

The plain token.

escaped in : string

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.


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.


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


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.