Re[2]: [fpc-devel] String and UnicodeString and UTF8Stringt

2011-01-12 Thread José Mejuto
Hello FPC,

Wednesday, January 12, 2011, 2:59:53 PM, you wrote:

>> 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 ?
L> It cann't .
L> Here I am speaking about TStringField, which is IMHO designed for 
L> character data, for binary data is designed TBinaryField

And a binary field is an string without encoding, collate and other
text explicit attributes.

>> But that's a problem of ODBC, but:
>> http://web.datadirect.com/resources/odbc/unicode/unix.html
L> Yes in UNIX world it may be so (I do not know),
L> but in Windows ODBC we have no such possibility AFAIK

Quote from Microsoft:
"The ODBC 3.5 (or higher) Driver Manager supports both ANSI and
Unicode versions of all functions that accept pointers to character
strings or SQLPOINTER in their arguments. The Unicode functions are
implemented as functions (with a suffix of W), not as macros. The ANSI
functions (which can be called with or without a suffix of A) are
identical to the current ODBC API functions."

ODBC 3.5 was launched around 2000-2001.

L> So it can be UTF-8, UTF-16 or UTF-32 ... in all cases we must allocate
L> space 4*[max.number of characters in field], right ?
L> So in what encoding are string data stored now in TStringField ?

In the same format the database bring them to it. Database returns a
bunch of bytes and a description of that bytes.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] String and UnicodeString and UTF8Stringt

2011-01-12 Thread José Mejuto
Hello FPC,

Wednesday, January 12, 2011, 11:02:00 AM, you wrote:

>> L> 2. Is it wrong in implementation of TSQLConnectors, which write data
>> L> into record buffer (of TStringField) and do not convert them always into
>> L> UTF-8 ?
>> Do you set the CHARSET field in your TSQLConnector to UTF-8 ?
L> not all connectors supports CharSet property. When I look into sources
L> only MySQL and IB support them (SQLite always return UTF-8 encoded ...
L> ODBC, Postgre and Oracle ignore it)

So partially it is a lack of support in TSQLConnector. Also UTF-8 in
Firebird does not work as expected due a design decision (I think).

L> Yes, this is not primary question of database side,

Oh yes it is! If you miss any of the three steps, it will fail:
1) Database field
2) SQLConnector and Client DLL/so
3) GUI

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 ? Client libraries have all the needed resources to handle
the database, a different thing is that SQLConnector implements them
and/or do it right.

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

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. In case you are using a DBF, in example which does not have
encoding information, you can use the transliterate facility of
dataset, but it is a bit awful.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] String and UnicodeString and UTF8Stringt

2011-01-12 Thread José Mejuto
Hello FPC,

Wednesday, January 12, 2011, 9:45:47 AM, you wrote:

L> 2. Is it wrong in implementation of TSQLConnectors, which write data
L> into record buffer (of TStringField) and do not convert them always into
L> UTF-8 ?

Do you set the CHARSET field in your TSQLConnector to UTF-8 ? Do you
define the right code page in each field of your database ?

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel