Bruce Eglington 1 Posted April 7 What is the best string definition for fields to use when working with a database using UTF-8 formated text fields. I have checked out numerous other blogs and forums, including Marco cantu's white paper but am left confused. Marco seems to suggest that defining fields as of type TUnicodeStringField is better than TWideStringField. Should all text fields for linking to databases be defined as TUnicodeStringField in the .DFM files and in the .PAS files? If so, I don't seem to be able to get this to work. I have only been able to implement TWideStringField. TStringField, which supposedly maps to TUnicodeStringField, also does not seem to work. I am currently using a Firebird 3.x database (defined as using UTF-8), together with Delphi 12.1 and am updating older databases that used to use only ASCII strings. Any guidance on the best practical option would be appreciated. Thanks Bruce 1 Share this post Link to post
Lars Fosdal 1848 Posted Tuesday at 08:45 AM Correct me if I'm wrong - but isn't the Delphi String automatically converted to/from UTF-8 (or other native db string formats) by FireDAC / Driver? Share this post Link to post
PeaShooter_OMO 34 Posted Tuesday at 10:23 AM (edited) 10 hours ago, Bruce Eglington said: TUnicodeStringField I am unsure about that class. In what unit is it declared? I can't find it in Delphi 11. Edited Tuesday at 10:23 AM by PeaShooter_OMO Share this post Link to post
Lajos Juhász 316 Posted Tuesday at 01:50 PM There is no TUnicodeStringField this is from the Delphi Unicode Migration (https://www.embarcadero.com/images/dm/technical-papers/delphi-unicode-migration.pdf😞 While this update makes the reading and writing of Unicode data in the TField classes consistent with the UnicodeString data type, and eliminates some potential data conversion issues, some of the class and member names in the TDataSet arena remain confusing. For example, there is no TUnicodeStringField type, and the TStringField class still stores its value as an AnsiString value. If you want a Unicode TField, you use TWideStringField (which, as mentioned in the preceding paragraph, is stored as a UnicodeString in Delphi 2009 and later). Share this post Link to post