EntityDAC UTF-8 strings
Posted: 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.
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.