String types in Delphi/Object Pascal -------------------------------------- (Possible) Delphi string types and types that auto converted to them in some form or the other: - 1 (ansi)char - 1 wide char, (both = char and widechar from now on) - 2 (static) array of both - 2 dynamic array of both. - 2 open array of both, - 2 pointer to both, - 2 pointer to array of both , - 3 short,ansi, (Delphi=COM) widestring types. - 1 open array shortstring. (openstring in Delphi2+ ?) - Kylix Widestring, Kylix and FPC before 2.6.x and still on non windows (D2009: - ansistring in a certain encoding (* times encoding) - ansistring[cp_utf8] // special case since 100% convertable to unicodestring - unicodestring - Haven't checked compabilities of pointer types, and if unicodechar=widechar. (yes it is, or both are word) - rawbytecodestring, which is essentially an open array type that takes both ansistring() without encoding. the primitive types are mostly already defined for widestring) ---- 16 (+3,4 in D2009, but way more if you count all encodings separately and if you see rawbytestring as a separate type ) Note that I didn't test all this. It was just what I could quickly think up. Theoretic maximal number of conversions: 16*16 = 256 (20^20=400) This is way too high of course: - assumes every conversion is possible (some like open arrays are possibly readonly), - assumes every conversion reversable. - also 16 direct assignments to same type are included, which are less prone to automatic conversion problems. - The types added by D2009 (unicodestring, rawbytestring, ansistring newstyle) have the same lowlevel basis which decreases conversions somewhat. It is too low because we count the various string[n] and ansistring[encoding] as one type: Some other remarks gathered from the various comments (IRC and c.l.p.delphi.misc) - Note that this even does not include some of these types in variants!!!!! Variants probably count as one stringtype (in the overloading sense) - literals. Are string literals different ? - Are there more types of literals? (e.g. unicode, pchar typed etc) - are there conversions, not over the base string types between literals and e.g. static array of char? - Delphi and FPC don't take type (as in x= TYPE y; ) very seriously, but it could be that these add even more, if there are such types in the RTL. - Rawbytestring and ansistring(encoding) seem to be closer related than I thought. An UTF16 string passed to rawbytestring is converted to the current 1-byte encoding. (not UTF8!)