EntityDAC UTF-8 strings

EntityDAC UTF-8 strings

Postby Chris_delta » Fri 12 May 2017 22:12

Hi all!

I'm using RAD Studio 10.2 and am currently trying out EntityDAC 1.6.12.

For test purposes I created a Firebird database with a table 'People', fields 'FIRSTNAME' and 'LASTNAME' (both VarChar, charset UTF-8 in the database).

I created a model with Entity Developer (Code-mapped Entities, Database first) and had the code created.

I then dropped the TEntityConnection, TEntityXMLModel, TEntityContext and a TIBDACDataProvider components onto my new data module and connected them accordingly.
My connection string on TEntityConnection is:
'Data Provider=IBDAC;SQL Dialect=InterBase;Login Prompt=False;Data Source=127.0.0.1;Database=C:\TEST.FDB;User ID=sysdba;Password=masterkey;Client Library=C:\fbclient.dll;Character Set=UTF8'

Next I dropped a TEntityQuery, with LINQ set to 'FROM P IN PERSONS' to get all records.

When I now right-click on the Query and choose 'Data Editor', the German name 'Günther' is shown as 'Günther'.

On the ConnectionString I tried the parameters 'UseUnicode=true' and 'Charset=UTF8' / 'Character Set=UTF8', all for themselves and in combination, the result is always the same, 'Günther'.

If I do 'UTF8ToWideString(EntityQuery1.FieldByName('FIRSTNAME').AsString);' it gives me the correct result.

For test purposes I also dropped a TIBCConnection, TIBCTransaction and TIBCQuery on the data module, Query with SQL 'SELECT * FROM PEOPLE', and 'UseUnicode' on the connection set to 'true', which also gives me the correctly spelled name.

Maybe I'm just stupid tonight (12 pm local time :) ), but I can't figure out how to get the correctly spelled name in the TEntityQuery.

Any help would be appreciated.
Chris_delta
 
Posts: 2
Joined: Fri 12 May 2017 21:50

Re: EntityDAC UTF-8 strings

Postby AlexP » Wed 17 May 2017 10:45

Hello,

To solve the problem you should change the fields type from string into widestring and enable the UseUnicode option
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35

Re: EntityDAC UTF-8 strings

Postby Chris_delta » Thu 18 May 2017 08:22

Changing from String to WideString did the trick, thanks a lot! :)
Chris_delta
 
Posts: 2
Joined: Fri 12 May 2017 21:50

Re: EntityDAC UTF-8 strings

Postby ViktorV » Fri 19 May 2017 10:15

Thank you for being interested in our products.
Feel free to contact us if you have any further questions about our products.
ViktorV
Devart Team
 
Posts: 1848
Joined: Wed 30 Jul 2014 07:16


Return to EntityDAC