Tutorial by Examples

Delphi has the following string types (in order of popularity): TypeMaximum lengthMinimum sizeDescriptionstring2GB16 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.AnsiStr...
uses System.Character; var S1, S2: string; begin S1 := 'Foo'; S2 := ToLower(S1); // Convert the string to lower-case S1 := ToUpper(S2); // Convert the string to upper-case
2009 uses Character; var C1, C2: Char; begin C1 := 'F'; C2 := ToLower(C1); // Convert the char to lower-case C1 := ToUpper(C2); // Convert the char to upper-case The uses clause should be System.Character if version is XE2 or above.
uses SysUtils; var S1, S2: string; begin S1 := 'Foo'; S2 := LowerCase(S1); // S2 := 'foo'; S1 := UpperCase(S2); // S1 := 'FOO';
Assigning string to different string types and how the runtime environment behaves regarding them. Memory allocation, reference counting, indexed access to chars and compiler errors described briefly where applicable. var SS5: string[5]; {a shortstring of 5 chars + 1 length byte, no trailing `0`...
Counting references on strings is thread-safe. Locks and exception handlers are used to safeguard the process. Consider the following code, with comments indicating where the compiler inserts code at compile time to manage reference counts: procedure PassWithNoModifier(S: string); // prologue: Inc...
String types like UnicodeString, AnsiString, WideString and UTF8String are stored in a memory using their respective encoding (see String Types for more details). Assigning one type of string into another may result in a conversion. Type string is designed to be encoding independent - you should nev...

Page 1 of 1