[yunqa.de] Re: CSVParser question

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sat, 18 Feb 2012 09:25:57 +0100

On 17.02.2012 21:51, Jon Burnham wrote:

> I am using your CSVParser and need to load a string and parse the 
> columns and rows to a Stringlist with CRLFs recognised.
> 
> I have taken your code and adjusted it, but I suspect that I am not
> loading the string properly.

I am sort of poking into the dark since I you don't know what kind of
string you are parsing: UnicodeString, AnsiString, does it contain
encoded characters?

Assuming your strings are of type "string", this code works for both
Unicode and non-Unicode Delphis:

  {$IFDEF Unicode}
  CsvParser.ReadMethods := Read_UTF_16_LE;
  CsvParser.SourceBufferAsStrW := s;
  {$ELSE Unicode}
  CsvParser.SourceBufferAsStrA := s;
  {$ENDIF Unicode}

If you string contains 8-bit encoded characters (AnsiString,
RawByteString), set CsvParser.ReadMethods to match the encoding.

If you need more help, I will need your sources (preferably a complete,
compilable project with all extra CSV files) for more specific advice.

Ralf
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: