Skip to content

Commit

Permalink
Add EscapeCharacter method
Browse files Browse the repository at this point in the history
  • Loading branch information
TollyH committed Jun 6, 2024
1 parent 0714501 commit 952d26f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ public static string EscapeCharacters(this string unescaped)
return unescaped.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("@", "\\@");
}

/// <summary>
/// Convert a char to its equivalent form as an escaped AssEmbly character literal.
/// </summary>
/// <remarks>Neither the input nor the output to this function have surrounding quote marks.</remarks>
public static string EscapeCharacter(this char character)
{
return character is '\\' or '\'' or '@' ? $"\\{character}" : $"{character}";
}

public static void SetContentTo<T>(this Stack<T> target, Stack<T> source)
{
target.Clear();
Expand Down

0 comments on commit 952d26f

Please sign in to comment.