[Lazarus] String vs WideString

Michael Van Canneyt michael at freepascal.org
Tue Aug 15 11:25:26 CEST 2017



On Tue, 15 Aug 2017, Mattias Gaertner via Lazarus wrote:

> On Mon, 14 Aug 2017 18:47:58 +0200
> Sven Barth via Lazarus <lazarus at lists.lazarus-ide.org> wrote:
>
>> [...]
>> The main problem of such a dynamic type would be the inability to do fast
>> indexing as the compiler would need to insert runtime checks for the size
>> of a character. I had already thought the same, but then had to discard the
>> idea due to this.
>
> IMHO the main problem of adding a new string type is
> https://xkcd.com/927/

Exactly. I don't think we should add even more.

As it is now, FPC offers a way out for all cases:

WideString/UnicodeString for those that want 2-byte characters.
A codepage-aware single-byte string for those that want 1-byte characters.
The shortstring is even still available.

Attempting to store binary data in a string is not advisable. 
Dynamic arrays, TBytes and - in the worst case - TBytesStream are powerful enough to
cover most use-cases in this area.

Michael.


More information about the Lazarus mailing list