Zero-based strings (Delphi)
Go Up to Delphi Compiler Directives (List) Index
Type |
Switch |
Syntax |
{$ZEROBASEDSTRINGS OFF} |
Default |
{$ZEROBASEDSTRINGS OFF} for Delphi desktop and mobile compilers. |
Scope |
Local |
Remarks
{$ZEROBASEDSTRINGS} controls the indexing used locally for string types.
Compilers (desktop and mobile) have as predefined {$ZEROBASEDSTRINGS OFF} indicating the use 1-based string indexes.
Note: Previous to Delphi 10.4 the mobile compilers used by default 0-based indexing for strings.
Attention: You can use {$ZEROBASEDSTRINGS} to change the local string indexing scheme. For example, in a Delphi application for mobile platforms, you can still use the old behavior by using {$ZEROBASEDSTRINGS ON}.
In general terms, string indexing is now uniform across platforms and uses 1-based index model.
Notice however that:
- Delphi string type helpers (TStringHelper) remain 0-based.
- All Delphi global flat functions are 1-based.