123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Uestc.Auto6.Dso.Protocol.RS232
- {
- static class ASCIIConverter
- {
- public static string GetASCIIStr(char c)
- {
- return (int)c switch
- {
- 0 => "NUL",
- 1 => "SOH",
- 2 => "STX",
- 3 => "ETX",
- 4 => "EOT",
- 5 => "EBQ",
- 6 => "ACK",
- 7 => "BEL",
- 8 => "BS",
- 9 => "HT",
- 10 => "LF",
- 11 => "VT",
- 12 => "FF",
- 13 => "CR",
- 14 => "SO",
- 15 => "SI",
- 16 => "DLE",
- 17 => "DC1",
- 18 => "DC2",
- 19 => "DC3",
- 20 => "DC4",
- 21 => "NAK",
- 22 => "SYN",
- 23 => "ETB",
- 24 => "CAN",
- 25 => "EM",
- 26 => "SUB",
- 27 => "ESC",
- 28 => "FS",
- 29 => "GS",
- 30 => "RS",
- 31 => "US",
- 32 => "SP",
- int ch when (ch >= 33 && ch <= 126) => System.Text.Encoding.ASCII.GetString(new byte[1] { (byte)ch}),
- 127 => "DEL",
- _=>"",
- };
- }
- }
- }
|