//
// The pos should point to a quote character. This method will
- // get the length, including beginning and ending quote, of the
- // quoted string.
+ // get the string encloed by the quote character.
//
- internal static int ParseQuoteString(String format, int pos)
+ internal static int ParseQuoteString(String format, int pos, StringBuilder result)
{
//
// NOTE : pos will be the index of the quote character in the 'format' string.
// minute: 45"
// because the second double quote is escaped.
if (pos < formatLen) {
- pos++;
+ result.Append(format[pos++]);
} else {
//
// This means that '\' is at the end of the formatting string.
//
throw new FormatException(Environment.GetResourceString("Format_InvalidString"));
}
+ } else {
+ result.Append(ch);
}
}
CultureInfo.CurrentCulture,
Environment.GetResourceString("Format_BadQuote"), quoteChar));
}
-
+
//
// Return the character count including the begin/end quote characters and enclosed string.
//
break;
case '\'':
case '\"':
- tokenLen = ParseQuoteString(format, i);
- result.Append(format, i + 1, tokenLen - 2);
+ StringBuilder enquotedString = new StringBuilder();
+ tokenLen = ParseQuoteString(format, i, enquotedString);
+ result.Append(enquotedString);
break;
case '%':
// Optional format character.
break;
case '\'':
case '\"':
- tokenLen = DateTimeFormat.ParseQuoteString(format, i);
- result.Append(format, i + 1, tokenLen - 2);
+ StringBuilder enquotedString = new StringBuilder();
+ tokenLen = DateTimeFormat.ParseQuoteString(format, i, enquotedString);
+ result.Append(enquotedString);
break;
case '%':
// Optional format character.