Search code examples
delphifiremonkey

In Sydney does string still zero based in mobile?


when I read the doc: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Migrating_Delphi_Code_to_Mobile_from_Desktop it's say that in mobile string is 0-Based, but I heard that it's not the case anymore, so is the doc inaccurate ?


Solution

  • "..so is the doc inaccurate ?"

    Yes, the document you are reading is not updated with the latest information.

    See Zero-based strings:

    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.

    You can still use zero-based strings by setting {$ZEROBASEDSTRINGS ON}

    Also from docs:

    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.