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

Graeme Geldenhuys graeme at geldenhuys.co.uk
Mon Jul 15 11:29:34 CEST 2013

On 2013-07-14 19: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.

Yeah, I have experienced that too. There really should be a .Size and
.DataSize property - or something similar.

Even setting the database to use Unicode text fields doesn't solve the
problem either - in then messes with the .Size property value in SqlDB.

My work-around is to simply use VarChar(), and make sure you add some
extra space for those Unicode fields. Then hold thumbs that the client
apps don't hit that limit. eg: I might have a business object that says
a field is 100 "characters" long. This limit gets applied to the user
interface too. But the database field is actually defined as
VarChar(150). This gives me 50 bytes extra for the occasional Unicode
character. Definitely not an ideal solution though.

  - Graeme -

More information about the Lazarus mailing list