[Lazarus] Charset in TSdfDataSet

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Thu Sep 6 14:32:12 CEST 2012



On Thu, 6 Sep 2012, Roberto P. wrote:

> 2012/9/6 GLBX <LBX at swing.be>

[snip]

>
> when working on that project of mine, I was in a hurry and I couldn't go
> deeper in understanding things (like the double conversion through UTF16,
> thanks Mattias).
> At that time I was also UNABLE to save back to csv through the sdf dataset,
> even with readonly = false, putting the db in edit/append and posting the
> changes.... it looked somehow a reader-only dataset.
>
> A quick (and maybe unefficient or dirty) trick to get around it has been to
> use:
> - a TSDFDataset to read the CSV file (my separtor was non-standard)
> - copying it to a TMemDataset which can be manipulated really fast
> - place a TCSVExporter component on the form (install in the palette from
> the dbexport package) connected to the TMemDataset
> When you're done with editing and posting, you can simply call
> TCSVExporter.Execute to save it to CSV.
>
> An alternative (that I couldn't explore due to the limited amount of time I
> had) might be this one:  http://wiki.freepascal.org/CsvDocument
> which supposedly reads and writes, either randomly (in memory) or
> sequentially, a CSV file.

Yes, but if you read that page carefully, you will see that

"Both UTF-8 encoding and windows-xxx codepages can be used with CsvDocument
library. The library uses string type for all string operations and will not
do any encoding conversion for you. Keep in mind though that Excel does not
support CSV files in UTF-8."

So you will experience the same problems.

Michael.




More information about the Lazarus mailing list