[fpc-devel] String and UnicodeString and UTF8Stringt

LacaK lacak at zoznam.sk
Wed Jan 12 14:59:53 CET 2011


> L> but db client library api, which is used by SQLConnector to
> L> retrieve data.
>
> How an UTF8 SQLConnector can retrieve UTF8 data from a field defined
> as binary ?
It cann't .
Here I am speaking about TStringField, which is IMHO designed for 
character data, for binary data is designed TBinaryField

> L> For example in ODBC we use SQLGetData in LoadField
> L> method to retrieve data from odbc interface. And for example in
> L> case of MS SQL Server character data are retrieved in current ANSI
> L> code page (in Windows of course, may be that for example in *nix
> L> data are retrieved in UTF-8 naturaly) .
>
> Via ODBC ?
>
> L> (AFAIK there is no universal way how to explicitly request
> L> character encoding from ODBC interface)
>
> But that's a problem of ODBC, but:
>
> http://web.datadirect.com/resources/odbc/unicode/unix.html
>   
Yes in UNIX world it may be so (I do not know),
but in Windows ODBC we have no such possibility AFAIK

> L> So it is true, that every sql connector is mandatory write character
> L> data in UTF-8 ?
>
> No. It is mandatory that you send/receive UTF8 to/from GUI LCL
> elements. 
As LCL elements are using TStringField.Text property, then this property 
should return UTF8String, right (not AnsiString in ANSI code page) ?
If yes, then also TStringField must store internaly data in any unicode 
format (to not lose any characters), right ?
So it can be UTF-8, UTF-16 or UTF-32 ... in all cases we must allocate 
space 4*[max.number of characters in field], right ?
So in what encoding are string data stored now in TStringField ?

-Laco.



More information about the fpc-devel mailing list