MaterialAsciiCode.cs 786 字节
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public static class MaterialAsciiCode
    {
        private static readonly Dictionary<string, string> ASCII_CODE = new() { { "[space]", " " }, { "[tab]", "\t" },{ "[gs]",((char)29).ToString()},{ "[rs]", ((char)30).ToString() } };

        public static string GetAsciiCode(string code)
        {
            if (code.StartsWith("[") && code.EndsWith("]"))
            {
                if (ASCII_CODE.TryGetValue(code.ToLower(), out string value))
                    return value;
                else
                    return code;
            }
            else
            {
                return code;
            }
        }

    }
}