[fpc-devel] Copy() and ZeroBaseStrings

Sven Barth pascaldragon at googlemail.com
Mon Apr 7 14:17:12 CEST 2025


Martin Frb via fpc-devel <fpc-devel at lists.freepascal.org> schrieb am Mo.,
7. Apr. 2025, 08:13:

> On 07/04/2025 08:01, Sven Barth via fpc-devel wrote:
> >
> > Also it would be best to simply document as UTF8Copy working 1-based
> > because you can't detect from the callee-side whether it had been
> > enabled on the caller-side (especially if they're from different units).
> >
>
> Just an idea.
>
> Maybe having 2 underlying string types for 0 and 1 based. Then it would
> be possible to use overload.
>

No. This would not be compatible with Delphi from which this feature stems.


> Btw, "from the calling side", before I search the doc, what happens if
>
> Unit1 // has 0 base strings
> var foo: ansistring; //global
> foo := 'abc';
>
> unit2 // has 1 based strings
> writeln(foo[1]);  // follows 1 based or follows declaration 0 based?
>

It has nothing to do with the declaration. It's a local switch that
controls whether a 1 is implicitly added by the compiler when accessing a
string using [] accesses or intrinsics.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20250407/644126ee/attachment.htm>


More information about the fpc-devel mailing list