[fpc-pascal] RTL and Unicode Strings

LacaK lacak at zoznam.sk
Wed May 11 11:47:39 CEST 2016


>> In other cases, like LacaK said, you will have to read the data as plain
>> bytes into e.g. a RawByteString and next use
>> http://www.freepascal.org/docs-html/rtl/system/setcodepage.html (with
>> the last parameter set to "false") to afterwards specify the code page
>> this data has.
> But this is where I'm getting a bit confused too.
>
> The RTL and FCL uses String data type predominantly.
>    eg: TField.AsString: String.
>
> The RTL and FCL uses String (AnsiString) with default encoding set to Auto.
>
> In my application I enable unicodestring mode. So I'm reading data from
> a Firebird database. The data is stored as UTF-8 in a VarChar field. The
> DB connection is set up as UTF-8.  Now lets assume my FreeBSD box is set
> up with a default encoding of Latin-1.
>
> So I read the UTF-8 data from the database, somewhere inside the SqlDB
> code it gets assigned to a TField's String property. ie: UTF-8 ->
> Latin-1 conversion.
IMO this does not happen.
Because sqlDB provides only pointers to field buffers where "sql 
connector" stores data which receives from server.
DB unit only allocates memory of given size and then provides pointer to 
that memory, where data are stored.
(may be that somewhere popups any issue, for now I still use FPC 2.6.4 
so I can not say more about FPC 3.0.0)
-Laco.



More information about the fpc-pascal mailing list