[yunqa.de] Re: CSVParser question

  • From: "Jon Burnham" <jba@xxxxxxxxxxxxxx>
  • To: <yunqa@xxxxxxxxxxxxx>
  • Date: Sat, 18 Feb 2012 09:04:22 -0000

Ralf, thank you, it works :-)

Does this mean that you have to set the encoding as mandatory - that there
is no default ?

Kind regards

Jon

-----Original Message-----
From: yunqa-bounce@xxxxxxxxxxxxx [mailto:yunqa-bounce@xxxxxxxxxxxxx] On
Behalf Of Delphi Inspiration
Sent: 18 February 2012 08:26
To: yunqa@xxxxxxxxxxxxx
Subject: [yunqa.de] Re: CSVParser question

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



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



Other related posts: