private IList<String> ParseCharSep(string line)
{
var item = new StringBuilder();
var result = new List<String>();
bool quoted = false;
bool hadQuotes = false;
for (int i = 0; i < line.Length; i++)
{
char ch = line[i];
if ((ch == Format.Separator) && !quoted)
{
String s = item.ToString();
if (!hadQuotes)
{
s = s.Trim();
}
result.Add(s);
item.Length = 0;
quoted = false;
hadQuotes = false;
}
else if ((ch == '\"') && quoted)
{
quoted = false;
}
else if ((ch == '\"') && (item.Length == 0))
{
hadQuotes = true;
quoted = true;
}
else
{
item.Append(ch);
}
}
if (item.Length > 0)
{
String s = item.ToString();
if (!hadQuotes)
{
s = s.Trim();
}
result.Add(s);
}
return result;
}