[Lazarus] Charset in TSdfDataSet

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Sep 6 12:04:26 CEST 2012

GLBX <LBX at swing.be> 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

> But I will get the problem back when validating changes in fields !!!
> (I Tried with OnSetText : but inefficient !)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120906/eb4e52bf/attachment-0003.html>

More information about the Lazarus mailing list