示例#1
0
 public string DecodeEscapedString(int end, int skip, Encoding encoding)
 {
     if (CheckValue('\"'))
     {
         var        sb    = new StringBuilder(end - Position);
         ByteString bs    = null;
         var        bytes = new byte[end - Position + 1];
         Skip();
         while (Position < end)
         {
             var c = ReadChar();
             if (c == '\\')
             {
                 var nc = CurrentChar;
                 if (nc.IsOctDigit())
                 {
                     if (bs == null)
                     {
                         var bufferSize = end - Position;
                         if (bufferSize < 1)
                         {
                             bufferSize = 1;
                         }
                         bs = new ByteString(end - Position);
                     }
                     int len   = 1;
                     int start = Position;
                     Skip();
                     while (CurrentChar.IsOctDigit())
                     {
                         Skip();
                         ++len;
                     }
                     bs.AppendByte(ByteFromOctString(String, start, len));
                 }
                 else
                 {
                     ByteString.Dump(bs, sb, encoding);
                     HandleEscapeCode(sb, nc);
                     Skip();
                 }
             }
             else if (c == '\"')
             {
                 ByteString.Dump(bs, sb, encoding);
                 break;
             }
             else
             {
                 ByteString.Dump(bs, sb, encoding);
                 sb.Append(c);
             }
         }
         Position = end + skip;
         return(sb.ToString());
     }
     else
     {
         return(ReadStringUpTo(end, skip));
     }
 }