[fpc-pascal] Generic String Functions

Sven Barth pascaldragon at googlemail.com
Fri Feb 28 12:53:17 CET 2014


Am 28.02.2014 09:37 schrieb "Michael Schnell" <mschnell at lumino.de>:
>
> ..Continuing the never ending discussion ...
>
> [ In one ore more other threads here I showed that (IMHO) it would be
most sensible (and in fact not performance killing (!) ) way out of the
multiple (statically defined) "new" String types with different encoding
(with auto-conversion) to additionally support a fully dynamically encoded
string type (with auto-conversion) - which needs some compiler magic - and
use same as the base type for TStrings and it's siblings. ]
>
> The growing popularity of "Generics" might suggest to call this String
encoding "Generic", too, (to easily tell it from the Delphi-introduced
"Raw", and the dedicated encoding types).
>
> Regarding arguments for it's usefulness I came across that the Lazarus
API currently forces TStrings to be UTF8 encoded while Delphi currently
forces TStrings to be UTF16 encoded. IMHO the only way to prevent
disastrous compatibility problems is to do TStrings being "Generic"encoded
and with that allow for decent portability for both.

Problem: there is (currently) no string type that can handle ANSI, UTF-8
and UTF-16 at once. The first two are handled by AnsiString and the third
by UnicodeString. And those two are not equal which would be important for
overrides/overloads/inheritance. Without that your whole idea is useless.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140228/a5ef8c21/attachment.html>


More information about the fpc-pascal mailing list