[fpc-pascal] The world is ending

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Mon May 9 23:37:05 CEST 2016


On 2016-05-09 21:14, Tomas Hajny wrote:
> about possible data loss isn't cause by the
> compiler but rather by the user who sets his environment to use a
> character set which can only process a limited subset of all possible
> characters while he intends to use a bigger set.

My issue is with String = AnsiString, where they could or couldn’t
support the full Unicode range. And the decision is made at runtime. The
same executable (think my company releasing software to the public)
could behave differently depending on the end-users environment.
CodeGear/Embarcadero saw the dangers in that, and thus forced String =
UnicodeString on all platforms.

The issue can occur anywhere, not just loading files from a hard disk.
eg: Reading data from a database. The data might be stored in UTF-8 or
UTF-8 and contain above char(255) data. Somewhere in TDataset (or any
component for that matter), that Unicode data might be assigned to a
String type. On your Linux system String = AnsiString(<utf8>), but on my
system in could be String = AnsiString(<latin1>). As a end-user you will
not get or see any warning - you’ll just end up with rubbish data.

Now from what you are saying (if I understood correctly), is that we now
need to tell every end-user they need to change their system’s code-page
settings just to run our software. Well, that will not fly. Plus, Qt,
C#, Mono and Java applications run and behave just fine on such systems,
and those languages support the full Unicode range.

G*d knows why Delphi introduced code-page aware AnsiStrings, when they
had a functioning UnicodeString type. Even worse is why FPC decided to
follow that horrible direction years later. There really should be a
limit to “delphi compatibility”.

Everybody knows how terrible the Variant data type is. Any respectable
programmer tries to avoid it at all costs. AnsiString (with its variable
internal encoding) is now equally bad. Unfortunately there are millions
and millions of lines of Object Pascal code where the String type is used.

Tomas, I can only hope a decision on the RTL’s future comes sooner
rather than later. In the mean time I’ll keep plugging away at tiOPF
with FPC 3.x and created patches for FPC’s RTL where I can.

Regards,
  Graeme




More information about the fpc-pascal mailing list