Utility class providing escaping functions
More...
|
static void | EscapeChars (char fieldSeparator, char commandSeparator, char escapeCharacter) |
| Sets custom escape characters. More...
|
|
static string | Remove (string input, char removeChar, char escapeChar) |
| Removes all occurences of a specific character unless escaped. More...
|
|
static String[] | Split (string input, char separator, char escapeCharacter, StringSplitOptions stringSplitOptions) |
| Splits. More...
|
|
static string | Escape (string input) |
| Escapes the input string. More...
|
|
static string | Unescape (string input) |
| Unescapes the input string. More...
|
|
Utility class providing escaping functions
static string CommandMessenger.Escaping.Escape |
( |
string |
input | ) |
|
|
inlinestatic |
Escapes the input string.
- Parameters
-
input | The unescaped input string. |
- Returns
- Escaped output string.
145 var escapeChars =
new[]
147 _escapeCharacter.ToString(CultureInfo.InvariantCulture),
148 _fieldSeparator.ToString(CultureInfo.InvariantCulture),
149 _commandSeparator.ToString(CultureInfo.InvariantCulture),
152 input = escapeChars.Aggregate(input,
153 (current, escapeChar) =>
154 current.Replace(escapeChar, _escapeCharacter + escapeChar));
static void CommandMessenger.Escaping.EscapeChars |
( |
char |
fieldSeparator, |
|
|
char |
commandSeparator, |
|
|
char |
escapeCharacter |
|
) |
| |
|
inlinestatic |
Sets custom escape characters.
- Parameters
-
fieldSeparator | The field separator. |
commandSeparator | The command separator. |
escapeCharacter | The escape character. |
78 _fieldSeparator = fieldSeparator;
79 _commandSeparator = commandSeparator;
80 _escapeCharacter = escapeCharacter;
static string CommandMessenger.Escaping.Remove |
( |
string |
input, |
|
|
char |
removeChar, |
|
|
char |
escapeChar |
|
) |
| |
|
inlinestatic |
Removes all occurences of a specific character unless escaped.
- Parameters
-
input | The input. |
removeChar | The character to remove. |
escapeChar | The escape character. |
- Returns
- The string with all removeChars removed.
91 var escaped =
new IsEscaped();
92 for (var i = 0; i < input.Length; i++)
94 char inputChar = input[i];
95 bool isEscaped = escaped.EscapedChar(inputChar);
96 if (inputChar != removeChar || isEscaped)
static String [] CommandMessenger.Escaping.Split |
( |
string |
input, |
|
|
char |
separator, |
|
|
char |
escapeCharacter, |
|
|
StringSplitOptions |
stringSplitOptions |
|
) |
| |
|
inlinestatic |
Splits.
- Parameters
-
input | The input. |
separator | The separator. |
escapeCharacter | The escape character. |
stringSplitOptions | Options for controlling the string split. |
- Returns
- The split string.
116 var result =
new List<string>();
117 for (var i = 0; i < input.Length; i++)
127 if (t == escapeCharacter)
130 if (i < input.Length - 1) t = input[++i];
136 if (stringSplitOptions == StringSplitOptions.RemoveEmptyEntries) result.RemoveAll(item => item ==
"");
137 return result.ToArray();
static string CommandMessenger.Escaping.Unescape |
( |
string |
input | ) |
|
|
inlinestatic |
Unescapes the input string.
- Parameters
-
input | The escaped input string. |
- Returns
- The unescaped output string.
165 for (var fromChar = 0; fromChar < input.Length; fromChar++)
167 if (input[fromChar] == _escapeCharacter)
171 output += input[fromChar];
char CommandMessenger.Escaping.EscapeCharacter |
|
staticget |
The documentation for this class was generated from the following file:
- D:/My Documents/Github/Arduino-Code-and-Libraries/Libraries/CmdMessenger/CSharp/CommandMessenger/Escaped.cs