diff --git a/Extensions.cs b/Extensions.cs index 8cf5a76..8fbf7bf 100644 --- a/Extensions.cs +++ b/Extensions.cs @@ -13,6 +13,15 @@ public static string EscapeCharacters(this string unescaped) return unescaped.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("@", "\\@"); } + /// + /// Convert a char to its equivalent form as an escaped AssEmbly character literal. + /// + /// Neither the input nor the output to this function have surrounding quote marks. + public static string EscapeCharacter(this char character) + { + return character is '\\' or '\'' or '@' ? $"\\{character}" : $"{character}"; + } + public static void SetContentTo(this Stack target, Stack source) { target.Clear();