Embarcadero Delphi Strings String types


Delphi has the following string types (in order of popularity):

TypeMaximum lengthMinimum sizeDescription
string2GB16 bytesA managed string. An alias for AnsiString through Delphi 2007, and an alias for UnicodeString as of Delphi 2009.
UnicodeString2GB16 bytesA managed string in UTF-16 format.
AnsiString2GB16 bytesA managed string in pre-Unicode ANSI format. As of Delphi 2009, it carries an explicit code-page indicator.
UTF8String2GB16 bytesA managed string in UTF-8 format, implemented as an AnsiString with a UTF-8 code page.
ShortString255 chars2 bytesA legacy, fixed-length, unmanaged string with very little overhead
WideString2GB4 bytesIntended 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.