FireDAC and UTF8 on Firebird

I have Firebird database with settings:

DEFAULT CHARACTER SET WIN1250;

In this database I have defined domain:

CREATE DOMAIN D_VARCHAR32 AS VARCHAR(32); <-- 32

and I use it in some columns, example:

CREATE TABLE SOMETABLE (
 ID INTEGER,
 UUID D_VARCHAR32   <--  32
); 
    

I know that WIN1250 is ansi code page. But I connect to this database with
UTF8 setting:

ADConnection.Params =
'User_Name=sysdba
Password=masterkey
Protocol=TCPIP
Server=localhost
CharacterSet=UTF8   <--- UTF
ExtendedMetadata=True
Database=C:\Bases\DB.FDB
DriverID=IB';

As a result of the query...

select * from SOMETABLE

....ADQuery creates a set of fields:

TIntegerField
TWideStringField

BUT field of TWideStringField type in "Size" property has value 128 - not
32! Why? 

FIBPlus dataset in this case created field of TFIBWideStringField type with
the correct Size = 32.

I use:
Firebird 2.5.1
Delphi XE
FireDAC 8.0.3

This is bug in FireDAC?


ps. 
I use connection with UTF8 because on a system that natively does not
support WIN1250 I have the correct characters (when I connected with
CharacterSet=WIN1250 I get bad/rubbish chars).
Converting a database to UTF8 will be the last resort.


-- 
pozdrawiam
Jacek
0
Jacek
6/10/2013 8:03:54 PM
embarcadero.delphi.firedac 822 articles. 2 followers. Follow

4 Replies
2702 Views

Similar Articles

[PageSpeed] 9

Dnia Mon, 10 Jun 2013 23:42:44 -0700, Dmitry Arefiev napisał(a):

>> Am I correct?
> 
> You are almost right. There must be "div 4". Where 4 is 
> maximum number of bytes per single UTF8 character.

Of course, it should be 4!

....and SizeOf(TADWideString) returns exactly 4 ;-)

But I know that it is bad solution (accidently good). SizeOf always return 4
for complex type. I wrote it at night, after a day of work, I was befuddled
;-)

-- 
pozdrawiam
Jacek
0
Jacek
4/14/2013 8:36:08 PM
Dnia Mon, 10 Jun 2013 13:03:54 -0700, Jacek Laskowski napisał(a):

> BUT field of TWideStringField type in "Size" property has value 128 - not
> 32! Why? 
> 
> FIBPlus dataset in this case created field of TFIBWideStringField type with
> the correct Size = 32.
> 
> I use:
> Firebird 2.5.1
> Delphi XE
> FireDAC 8.0.3
> 
> This is bug in FireDAC?

I debugged FireDAC library and I found in uADPhysIB.pas a piece of code:

case ASQLDataType of 
  SQL_TEXT, 
  SQL_VARYING, 
  SQL_NULL: 
    if LongWord(ASQLLen) <= AFmtOpts.MaxStringSize then begin 
      if ASQLSubType = csIDOctets then begin 
        AType := dtByteString; 
        ALen := ASQLLen; 
      end 
      else if IBConnection.FEnv.Lib.IsUTF8(ASQLSubType) then begin 
        AType := dtWideString; 
        ALen := ASQLLen; <------------ why not "div SizeOf(TADWideString)" ?
      end 
      else begin 
        AType := dtAnsiString; 
        ALen := ASQLLen div SizeOf(TADAnsiChar); 
      end;

I indicate the place where divide will helping to get correct field size. 
Am I correct?

-- 
pozdrawiam
Jacek
0
Jacek
6/10/2013 9:13:13 PM
> Am I correct?

You are almost right. There must be "div 4". Where 4 is 
maximum number of bytes per single UTF8 character.

-- 
With best regards,
Dmitry Arefiev / FireDAC Architect
FireDAC - Firebird, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, 
DB2, SQL Anywhere, Access, Informix, ODBC high-speed data access lib
0
Dmitry
6/11/2013 6:42:44 AM
> Of course, it should be 4!

Actually, the final solution is more complex and returns
a value depending on character set and DBMS brand 
and client software version.

But for Firebird 2.5 and UTF8 you can use 4.

-- 
With best regards,
Dmitry Arefiev / FireDAC Architect
FireDAC - Firebird, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, 
DB2, SQL Anywhere, Access, Informix, ODBC high-speed data access lib
0
Dmitry
6/11/2013 9:15:04 AM
Reply:

Similar Artilces:

FireDAC and Delphi Pro XE4... firedac tab not visible?
I am moving from a very old Borland product (2006) to Delphi XE4 Professional with FireDAC addon. I purchased both from Embarcadero, and have downloaded both. The documentation says the FireDAC components should automagically appear in the tabset for Delphi. They do not. I don't want to fool around too much as my environment is strictly controlled by IT, and they are very slow to do anything. Is there something that I should have done, but did not do? I installed XE4 first, registered it, then used the link in my email from Embarcadero to download the FireDAC components. Then I ra...

Delphi XE3 FireDAC TADConnection: Firebird driver not in Driver ID list
Delphi XE3 Enterprise FireDAC TADConnection Firebird driver not in Driver ID list Hi to all, I use Delphi XE3 Enterprise and have just installed FireDAC 7.0.1, but trying the sample "getting started" application, I can't find Firebird in the Driver ID list. I can see ADS, ASA, DataSnap, etc but no Firebird. By the way, all the DBExpress applications are running fine with Firebird. Is something I have missed? Hernando. Hello Hernando 'FB' driver ID was introduced in FireDAC v 9.0.1 (XE5). Before that existed only 'IB' driver ID. To workaround ...

FireDac
Hello, I am using Delphi XE4 and facing a problem with FireDac (8.0.5) and MySQL. I'm trying to get the last 100 records from a large table (20 million rows). When I run the following SQL: {code}select * from largetable order by FId limit 100{code} in MySQL Workbench it returns in 0.2 seconds. When I run the above SQL in Delphi through an ADQuery it never returns (Delphi freezes). Any Ideas ? Thank you ...

FireDAC / Delphi XE7 / Firebird 2.5 + Dialect 3: Key fields turn upper case
Hi, When working wih a SQL dialect 3 database and field names in upper/lower case, I used to reference those fields in double quotes on my old Delphi 2010 with IBX, which worked well enough. After migrating to XE7 with the latest FireDAC, I set IndexFieldNames to "Mmm" including the double quotes. When opening the table, FireDAC executes an SQL statement that ends with {code}ORDER BY A."Mmm" ASC, A.MMM ASC{code} which of course delivers an exception because there is no field MMM. I hope it is ok if I post some single lines of code here to explain the issue - no copyri...

FireDAC / Delphi XE7 / Firebird 2.5 + Dialect 3: Key fields turn upper case [Edit]
Hi, When working wih a SQL dialect 3 database and field names in upper/lower case, I used to reference those fields in double quotes on my old Delphi 2010 with IBX, which worked well enough. After migrating to XE7 with the latest FireDAC, I set IndexFieldNames to "Mmm" including the double quotes. When opening the table, FireDAC executes an SQL statement that ends with {code}ORDER BY A."Mmm" ASC, A.MMM ASC{code} which of course delivers an exception because there is no field MMM. I hope it is ok if I post some single lines of code here to explain the issue - no copyri...

FireDAC / Delphi XE7 / Firebird 2.5 + Dialect 3: Key fields turn upper case [Edit]
Hi, When working wih a SQL dialect 3 database and field names in upper/lower case, I used to reference those fields in double quotes on my old Delphi 2010 with IBX, which worked well enough. After migrating to XE7 with the latest FireDAC, I set IndexFieldNames to "Mmm" including the double quotes. "Mmm" is also my only primary key field. When opening the table, FireDAC executes an SQL statement that ends with {code}ORDER BY A."Mmm" ASC, A.MMM ASC{code} which of course delivers an exception because there is no field MMM. I hope it is ok if I post some singl...

FireDAC / Delphi XE7 / Firebird 2.5 + Dialect 3: Key fields turn upper case [Edit] #2
Hi, When working wih a SQL dialect 3 database and field names in upper/lower case, I used to reference those fields in double quotes on my old Delphi 2010 with IBX, which worked well enough. After migrating to XE7 with the latest FireDAC, I set IndexFieldNames to "Mmm" including the double quotes. "Mmm" is also my only primary key field. When opening the table, FireDAC executes an SQL statement that ends with {code}ORDER BY A."Mmm" ASC, A.MMM ASC{code} which of course delivers an exception because there is no field MMM. I hope it is ok if I post some singl...

FireDac Delphi Xe2
Hello, I have FireDac components installed to Delphi Xe2, My version of FireDac is 8.0.1 but in this version I have probelm with TAdoquery with StrsEmpty2Null param. It doesn't work. Maybe someone know what I have to change in FiredAc source to remove this issue. To set the Param on NULL value before executing the query I do: {code} with qryExample.ParamByName('Example_id') do Begin DataType:=ftInteger; Clear; // Bound := True; End; {code} > {quote:title=Robert Triest wrote:}{quote} > To set the Param on NULL value before executing the query I do: >...

FireDac Delphi Xe2
Hello, I have FireDac components installed to Delphi Xe2, My version of FireDac is 8.0.1 but in this version I have probelm with TAdoquery with StrsEmpty2Null param. It doesn't work. Maybe someone know what I have to change in FiredAc source ro remove this issue. I suggest to the FireDAC newgroup. You'll probably get a better response there. Sebastian Kumor wrote: > Hello, > I have FireDac components installed to Delphi Xe2, > My version of FireDac is 8.0.1 but in this version I have probelm with TAdoquery with StrsEmpty2Null param. > It doesn't work. Mayb...

FireDAC for Delphi 2007 ?
Hello, I would like to know if FireDAC Client/Server Pack can be installed on Delphi 2007 pro. Thanks, Regards, Emmanuel Lion FireDAC Client/Server Pack for XE5 - No FireDAC Client/Server Pack for XE4/XE3, see: http://support.embarcadero.com/article/42970 M. E.L. wrote: > Hello, > > I would like to know if FireDAC Client/Server Pack > can be installed on Delphi 2007 pro. > > Thanks, > Regards, > > Emmanuel Lion > On 02.10.2013 18:17, quinn wildman wrote: > FireDAC Client/Server Pack for XE5 - No > FireDAC Client/Server Pack ...

It is FireDAC after all
Marco announces FireDAC: http://blog.marcocantu.com/blog/firedac_announced.html -- Nick The Buy Now button almost work ;-) > {quote:title=Nick Hodges wrote:}{quote} > Marco announces FireDAC: > > http://blog.marcocantu.com/blog/firedac_announced.html > That was fast :) delete this message > What's the price for XE3 Pro licensees? Introductory price is $399 -- With best regards, Dmitry Arefiev / FireDAC Architect http://www.embarcadero.com/products/rad-studio/firedac > All the links I found just go to a page that lets you purchase Delp...

FireDac Delphi Xe2
Hello, I have FireDac components installed to Delphi Xe2, My version of FireDac is 8.0.1 but in this version I have probelm with TAdoquery with StrsEmpty2Null param. It doesn't work. Maybe someone know what I have to change in FiredAc source ro remove this issue. I suggest to the FireDAC newgroup. You'll probably get a better response there. Sebastian Kumor wrote: > Hello, > I have FireDac components installed to Delphi Xe2, > My version of FireDac is 8.0.1 but in this version I have probelm with TAdoquery with StrsEmpty2Null param. > It doesn't work. Mayb...

FireDAC?
I'm starting a new development initiative and want to pick the tech that will last the longest and have the most complete feature set. Elsewhere someone noted that DBExpress has been deprecated in favour of FireDAC. I seem to have missed the announcement of FireDAC. So I'm looking for any info on what FireDAC is and why I should use it. Any links? I just discovered the FireDAC newsgroup and the first message there is an announcement with links to the product info and documentation. So my basic question (What is it?) is answered. Still don't know the future of DBExpr...

FireDac Delphi Xe2
Hello, I have FireDac components installed to Delphi Xe2, My version of FireDac is 8.0.1 but in this version I have probelm with TAdoquery with StrsEmpty2Null param. It doesn't work. Maybe someone know what I have to change in FiredAc source to remove this issue. To set the Param on NULL value before executing the query I do: {code} with qryExample.ParamByName('Example_id') do Begin DataType:=ftInteger; Clear; // Bound := True; End; {code} > {quote:title=Robert Triest wrote:}{quote} > To set the Param on NULL value before executing the query I do: >...

Web resources about - FireDAC and UTF8 on Firebird - embarcadero.delphi.firedac

Firebird.com - Creative Services and Copywriting for Advertising, Design, PR and Music Video Productions ...
Firebird is a Creative Service Collectives providing Design Concepts, Copy and Script Writing, Song Writing, Firebird Music Production and Video ...

Pontiac Firebird - Wikipedia, the free encyclopedia
The Pontiac Firebird is an automobile which was built by the Pontiac division of General Motors between 1967 and 2002. The Firebird was introduced ...

Firebird: The true open source database for Windows, Linux, Mac OS X and more
Firebird SQL: The true open-source relational database

Queensland Firebirds (@TheFirebirds) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Queensland Firebirds @ TheFirebirds ...

ANZ Championship semi-final Live: Queensland Firebirds v Northern Mystics
The Queensland Firebirds host the Northern Mystics for a spot in their fourth grand final in five years.

Corletto cops nasty knock as Firebirds win (01:27)
NSW Swifts defender Julie Corletto sustains a nose injury during the ANZ Championship final as the Queensland Firebirds take out the thrilling ...

Firebirds' success demands permanent home
Queensland Firebirds captain Laura Geitz says the state's netball community deserves a new home.

Stephen Grott, of Dalby, jailed for stalking Firebirds netballer Romelda Aiken and others, using the ...
THE online predator who stalked Queensland Firebirds netball champion Romelda Aiken will spend a year in jail after pleading guilty to preying ...

Thunderbirds defenders respond to challenge against Queensland Firebirds
... coach Jane Woodlands-Thompson was full of praise for defender Sam Poolman after yesterday&#8217;s frustrating loss to the Queensland Firebirds ...

Live 2015 ANZ Championship Grand Final: Queensland Firebirds vs. NSW Swifts - Other Sports - Fox Sports ...
... the ANZ Championship. The Swifts led the entire game at the Brisbane Entertainment Centre, but with less than 30 seconds on the clock the Firebirds ...

Resources last updated: 12/20/2015 8:25:50 AM