function SplitWithSpace(const S: String; QuoteChar: Char): TWords;<br>var<br> i, m, n: Integer;<br> Len: Integer;<br> ct: Integer;<br> InQuote: Boolean;<br>begin<br> Len := Length(S);<br> i := 1;<br> ct := 0;<br> InQuote := False;<br> while i <= Len do<br> begin<br> //跳过一到多个空格<br> while (i <= Len) and (S = ' ') do i := i + 1;<br> m := i;<br> while (i <= Len) and ((S <> ' ') or InQuote) do<br> begin<br> if S = QuoteChar then<br> InQuote := not InQuote;<br> i := i + 1;<br> end;<br> n := i;<br> if n > m then<br> begin<br> SetLength(Result, ((ct + 10) div 10) * 10);<br> Result[ct] := Copy(S, m, n - m);<br> ct := ct + 1;<br> end;<br> end;<br> SetLength(Result, ct);<br>end;<br><br>function UnQuoteString(const S: String): String;<br>var<br> m, n: Integer;<br>begin<br> if Length(s) = 0 then Exit;<br> m := 1;<br> if S[1] = '"' then m := 2;<br> n := Length(S);<br> if S[n] = '"' then n := n - 1;<br> Result := Copy(S, m, n - m + 1);<br>end;