[Lazarus] Losing data when saving Database fileds with "Size" defined and UTF8 chars

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon Jul 15 18:43:05 CEST 2013


Reinier Olislagers schrieb:
> On 14-7-2013 8:00, Daniel Simoes de Ameida wrote:
>> When the FieldDefs.Size properties is defined and we are trying to save
>> UTF8 characters with accented words, the Data is Truncated.
> Could be because UTF8 with accented characters may result in multiple
> bytes per character.
> If the size is too small, the number of bytes passed to the db won't fit.
> 
> The difference between specifying size in bytes and in characters still
> needs to be addressed.
> AFAIR, there's already a bug open for this.
> 
> Workaround: make your field size as large as the maximum number of UTF8
> bytes you expect.

Another workaround: use the appropriate codepage for storing strings in 
the database, so that all characters are single bytes. With the new 
(encoded) AnsiStrings this should be quite easy (automatic conversion).

DoDi





More information about the Lazarus mailing list