TStringHelper = record helper for string
typedef void *TStringHelper;
Record helper that provides functions and properties for working with all strings, including both 1-based and 0-based strings.
TStringHelper is a record helper for the intrinsic string type and provides helper methods that are accessible from string types as if the helper methods were methods of a class or record.
The Delphi mobile compilers (DCCIOS32 and DCCIOSARM) introduce 0-based indexing for strings. The Delphi desktop compilers continue to support 1-based strings, but interfaces and dynamic arrays are 0-based for all Delphi compilers. This change is further discussed in Migrating Delphi Code to iOS from Desktop.
Indexing for string types is different according to the compiler in use, as shown in the following table.
|Indexing of Strings in the Delphi Compilers|
|Delphi Compilers||String Indexing|
Delphi mobile compilers
Delphi desktop compilers
Always using TStringHelper methods to handle strings enables you to write code for multiple compilers and multiple platforms without using conditionals such as the IFDEF directive.
var MyString: String; begin MyString := 'This is a string.'; Writeln(myString.IndexOf('a', 0, 0)); //Working with zero-based or 1-based strings Writeln(Pos('a', myString)); //Working with 1-based strings end.
- Note: You are encouraged to move to the TSringHelper methods when manipulating strings on all platforms. To preserve backward compatibility with existing code as much as possible, the longstanding functions in the System unit that deal with string indices will continue to function with 1-based strings, and also perform the necessary automatic conversions to do the correct operations on 0-based strings as well. One example is System.Pos. However, these older System unit string-handling functions are deprecated and support might be removed in the future.