Untitled
unknown
csharp
7 days ago
1.6 kB
4
Indexable
Never
using System.Text; namespace MES_DualScanner { public class ControlChars { private static readonly Dictionary<char, string> ControlCharMap = new Dictionary<char, string> { {'\x00', "NUL"}, {'\x01', "SOH"}, {'\x02', "STX"}, {'\x03', "ETX"}, {'\x04', "EOT"}, {'\x05', "ENQ"}, {'\x06', "ACK"}, {'\x07', "BEL"}, {'\x08', "BS"}, {'\x09', "TAB"}, {'\x0A', "LF"}, {'\x0B', "VT"}, {'\x0C', "FF"}, {'\x0D', "CR"}, {'\x0E', "SO"}, {'\x0F', "SI"}, {'\x10', "DLE"}, {'\x11', "DC1"}, {'\x12', "DC2"}, {'\x13', "DC3"}, {'\x14', "DC4"}, {'\x15', "NAK"}, {'\x16', "SYN"}, {'\x17', "ETB"}, {'\x18', "CAN"}, {'\x19', "EM"}, {'\x1A', "SUB"}, {'\x1B', "ESC"}, {'\x1C', "FS"}, {'\x1D', "GS"}, {'\x1E', "RS"}, {'\x1F', "US"}, {'\x7F', "DEL"} }; public static string ConvertControlCharsToText(string input) { StringBuilder result = new(input); foreach (KeyValuePair<char, string> entry in ControlCharMap) { result.Replace(entry.Key.ToString(), $"<{entry.Value}>"); } return result.ToString(); } } }
Leave a Comment