Page 1 of 1

EntityDAC UTF-8 strings

Posted: Fri 12 May 2017 22:12
by Chris_delta
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=;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.

Re: EntityDAC UTF-8 strings

Posted: Wed 17 May 2017 10:45
by AlexP

To solve the problem you should change the fields type from string into widestring and enable the UseUnicode option

Re: EntityDAC UTF-8 strings

Posted: Thu 18 May 2017 08:22
by Chris_delta
Changing from String to WideString did the trick, thanks a lot! :)

Re: EntityDAC UTF-8 strings

Posted: Fri 19 May 2017 10:15
by ViktorV
Thank you for being interested in our products.
Feel free to contact us if you have any further questions about our products.