private string ReadQuotedColumn()
{
// Skip opening quote character
Debug.Assert (CurrPos < CurrLine.Length && CurrLine [CurrPos] == Quote);
CurrPos++;
// Parse column
StringBuilder builder = new StringBuilder ();
while (true) {
while (CurrPos == CurrLine.Length) {
// End of line so attempt to read the next line
CurrLine = Reader.ReadLine ();
CurrPos = 0;
// Done if we reached the end of the file
if (CurrLine == null)
return builder.ToString ();
// Otherwise, treat as a multi-line field
builder.Append (Environment.NewLine);
}
// Test for quote character
if (CurrLine [CurrPos] == Quote) {
// If two quotes, skip first and treat second as literal
int nextPos = (CurrPos + 1);
if (nextPos < CurrLine.Length && CurrLine [nextPos] == Quote)
CurrPos++;
else
break; // Single quote ends quoted sequence
}
// Add current character to the column
builder.Append (CurrLine [CurrPos++]);
}
if (CurrPos < CurrLine.Length) {
// Consume closing quote
Debug.Assert (CurrLine [CurrPos] == Quote);
CurrPos++;
// Append any additional characters appearing before next delimiter
builder.Append (ReadUnquotedColumn ());
}
// Return column value
return builder.ToString ();
}