示例#1
0
        public static string ReplaceEscapedValues(string text)
        {
            var matcher = new Matcher();

            if (matcher.IsMatch(text, "'`x_' /(['0-9a-f_']+)"))
            {
                for (var i = 0; i < matcher.MatchCount; i++)
                {
                    matcher[i] = getCharFromInt(HexParser.GetNumber(matcher[i, 1]));
                }

                text = matcher.ToString();
            }

            if (matcher.IsMatch(text, "'`o_' /(['0-7_']+)"))
            {
                for (var i = 0; i < matcher.MatchCount; i++)
                {
                    matcher[i] = getCharFromInt(OctParser.GetNumber(matcher[i, 1]));
                }

                text = matcher.ToString();
            }

            if (matcher.IsMatch(text, "'`b_' /(['01_']+)"))
            {
                for (var i = 0; i < matcher.MatchCount; i++)
                {
                    matcher[i] = getCharFromInt(BinParser.GetNumber(matcher[i, 1]));
                }

                text = matcher.ToString();
            }

            if (matcher.IsMatch(text, "'`' /(['0-9_']+)"))
            {
                for (var i = 0; i < matcher.MatchCount; i++)
                {
                    matcher[i] = getCharFromInt(matcher[i, 1].Replace("_", "").ToInt());
                }

                text = matcher.ToString();
            }

            return(text);
        }