2012/9/6 GLBX
Show quoted text 23 lines
**
Right !
with Textout, I get accents correctly
but... when I post the changes, now, I get the problem
Originally DAMMANS
Changed to D?MMANS
Display after editing
D?MMANS (coorect)
Saved in the CSV file as !!!!!
D??MMANS
and...
when I display after new loading :
D?MMANS (!!!!?!?!?!)
Oups !!
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.
R#
Show quoted text 53 lines
GLBX
----- Original Message -----
*From:* Mattias Gaertner
*To:* Lazarus mailing list
*Sent:* Thursday, September 06, 2012 12:04 PM
*Subject:* Re: [Lazarus] Charset in TSdfDataSet
GLBX hat am 6. September 2012 um 11:36 geschrieben:
> Hi,
>
> I checked the encodings and got :
>
> - GuessEncoding(dataset .fields[1].asString) and got UTF8
Keep in mind that it is impossible to reliably get the codepage of a
text, unless the text begins with a BOM. GuessEncoding simply checks if the
string validates some UTF-8 rules. If it is valid it returns UTF-8
otherwise the system code page.
> - [application]defaultTextEncoding = cp1252
>
> Now in DBGrid I wrote in DrawColumnCell :
> ...
> ExtTextOut( ....
UTF8ToISO_8859_1(dataCSV.Fields[datacol].AsString......)
> and.....
> Now accents are correctly displayed...
It seems you are calling the windows API function ExtTextOut directly
instead of the x-platform LCL one. The LCL one expects UTF-8, so you don't
need the conversion.
> But I will get the problem back when validating changes in fields !!!
> (I Tried with OnSetText : but inefficient !)
Mattias
------------------------------
--
_______________________________________________
Lazarus mailing list
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
--
_______________________________________________
Lazarus mailing list
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120906/1e14a75a/attachment.html>