private static int GetNextQuote(ref string s, int sidx, StreamReader sr) { int i = -1; while (i < 0) { i = s.IndexOf('"', sidx); if (i < 0) { int length = s.Length; s = s + "\r\n" + sr.ReadLine(); sidx = length + 2; } else { int cnt = CsvFileHelper.CountContinuousQuotes(s, i); if (cnt % 2 == 1) { i += cnt - 1; } else { sidx = i + cnt; i = -1; } } } return(i); }
private static string GetOneField(ref string s, StreamReader sr) { int n = CsvFileHelper.CountContinuousQuotes(s, 0); if (CsvFileHelper.IsStartWithQuote(s, n)) { return(CsvFileHelper.GetQuoteField(ref s, n, sr)); } var rtVal = string.Empty; int len = s.IndexOf(','); if (len < 0) { len = s.Length; } rtVal = ((len == 0) ? "" : s.Substring(0, len)); s = ((len >= s.Length - 1) ? "" : s.Substring(len + 1)); return(rtVal); }