コード例 #1
0
        /// <summary>
        /// Converts <see cref="EscapeMatch"/> to <see cref="char"/>.
        /// </summary>
        /// <param name="escapeMatch">Escape sequence wrapper class instance.</param>
        /// <returns>Result char.</returns>
        protected char ResolveDqsEscapeChar(EscapeMatch escapeMatch)
        {
            var text = escapeMatch.Value;

            //This is EscSeq
            switch (text[1])
            {
            //'$'|'b'|'f'|'n'|'r'|'t'|'v'
            case '"':
            case '\'':
            case '\\':
            case '/':
            case '$':
                return(text[1]);

            case 'b':
                return((char)8);

            case 'f':
                return((char)0xC);

            case 'n':
                return((char)0xA);

            case 'r':
                return((char)0xD);

            case 't':
                return((char)0x9);

            case 'v':
                return((char)0xB);

            case 'u':
                return(Convert.ToChar(Convert.ToUInt32(text.Substring(2), 16)));
            }
            return((char)0); //should never reach this code if parser works correctly
        }
コード例 #2
0
        /// <summary>
        /// Resolves escape sequence
        /// </summary>
        /// <param name="escapeMatch">Escape sequence wrapper class instance.</param>
        /// <param name="sb"><see cref="StringBuilder"/> used to build the literal value of the pair.</param>
        protected virtual void ResolveDqsEscape(EscapeMatch escapeMatch, StringBuilder sb)
        {
            char c = ResolveDqsEscapeChar(escapeMatch);

            sb.Append(c);
        }