[fpc-pascal] code example where AnsiString used in FCL (SqlDB) causes data loss

Jonas Maebe jonas.maebe at elis.ugent.be
Wed May 11 14:27:32 CEST 2016


Graeme Geldenhuys wrote on Wed, 11 May 2016:

> On 2016-05-11 13:05, Jonas Maebe wrote:
>>
>> Your concern is with utf8string, not with string/ansistring.
>> UTF8String is a AnsiString with utf-8 code page set.
>> If you
>> only use string/ansistring/unicodestring, then the behaviour of your
>> program will be identical with FPC 2.6.4 and 3.0. With utf8string, the
>> result is different in FPC 3.0 because now, just like when assigning
>
> No it's not. I welcome you to try the program yourself. The test program
> includes a $DEFINE where I can toggle between using String or
> UTF8String. Simply disable that define at the top of the unit.

That's because you have {$modeswitch unicodestring}, so  
string=unicodestring. If you change the string to unicodestring (since  
FPC 2.6.4 does not know {$modeswitch unicodestring}), you should get  
the same results in FPC 2.6.4 and FPC 3.x (since then they are also  
actually using the same string type).

I can't easily try myself as I have no database server whatsoever  
running, nor any experience with setting them up.


Jonas



More information about the fpc-pascal mailing list