[Lazarus] Charset in TSdfDataSet
LBX at swing.be
Thu Sep 6 11:36:12 CEST 2012
I checked the encodings and got :
- GuessEncoding(dataset .fields.asString) and got UTF8
- [application]defaultTextEncoding = cp1252
Now in DBGrid I wrote in DrawColumnCell :
ExtTextOut( .... UTF8ToISO_8859_1(dataCSV.Fields[datacol].AsString......)
Now accents are correctly displayed...
But I will get the problem back when validating changes in fields !!!
(I Tried with OnSetText : but inefficient !)
I go on looking for solution....
----- Original Message -----
From: "Mattias Gaertner" <nc-gaertnma at netcologne.de>
To: <lazarus at lists.lazarus.freepascal.org>
Sent: Thursday, September 06, 2012 9:45 AM
Subject: Re: [Lazarus] Charset in TSdfDataSet
> On Thu, 6 Sep 2012 09:22:57 +0200
> "Roberto P." <padovani.r at gmail.com> wrote:
>> I have recently dealt with a CSV file and accents.
>> I concluded that the TSdfDataSet had no problem with reading the file; I
>> was using a TMemo to show the strings and to see them correctly I had to
>> write something like this:
>> Memo.Lines.Text := UTF8Encode(SdfDataSet.Fields.AsString)
> UTF8Encode converts a widestring to an UTF8 string. AsString returns an
> ansistring. So the above first converts from system codepage to
> widestring (UTF16) and then to UTF8.
>> I'm no expert at all, especially about string encoding, so maybe someone
>> else could better explain what we should with the string format in the
>> DataSet and in the LCL components, but that should make you work in the
> I'm no sdf expert, so I will assume it does no conversion like most
> LCL code:
> If the csv file is in UTF8 and sdf does no conversion, then you can
> simply load the csv file and don't need any conversion at all.
> If the csv file is in the french windows code page 1252 then you can
> use the function ConvertEncoding of the LazUtils unit lconvencoding to
> convert its content to UTF8 before loading it into sdf.
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
More information about the Lazarus