Delphi has the following string types (in order of popularity):
Type | Maximum length | Minimum size | Description |
---|---|---|---|
string | 2GB | 16 bytes | A managed string. An alias for AnsiString through Delphi 2007, and an alias for UnicodeString as of Delphi 2009. |
UnicodeString | 2GB | 16 bytes | A managed string in UTF-16 format. |
AnsiString | 2GB | 16 bytes | A managed string in pre-Unicode ANSI format. As of Delphi 2009, it carries an explicit code-page indicator. |
UTF8String | 2GB | 16 bytes | A managed string in UTF-8 format, implemented as an AnsiString with a UTF-8 code page. |
ShortString | 255 chars | 2 bytes | A legacy, fixed-length, unmanaged string with very little overhead |
WideString | 2GB | 4 bytes | Intended for COM interop, a managed string in UTF-16 format. Equivalent to the Windows BSTR type. |
UnicodeString
and AnsiString
are reference counted and copy-on-write (COW).
ShortString
and WideString
are not reference counted and do not have COW semantics.