Description |
The AnsiChar type is used to hold single characters. It is guaranteed to be 8 bits in size.
At the time of writing, it is the same size as Char but the latter may change in the future.
It can be assigned from a character or integer value.
|
|
Related commands |
AnsiString |
|
A data type that holds a string of AnsiChars |
Char |
|
Variable type holding a single character |
PAnsiChar |
|
A pointer to an AnsiChar value |
WideChar |
|
Variable type holding a single International character |
|
|
|
Example code : Different ways of assigning to and from an AnsiChar |
var
myChar : AnsiChar;
begin myChar := 'G'; // Assign from a character constant
WriteLn('Letter G = '+myChar);
myChar := #65; // Assign from an integer constant
WriteLn('#65 = '+myChar);
myChar := ^I; // Assign from a control char - tab
WriteLn('Control '+myChar+' character');
myChar := Chr(66); // Using Chr to convert a number
WriteLn('Chr(66) = '+myChar);
myChar := Char(67); // Using Char as a standard cast
WriteLn('Char(67) = '+myChar);
end;
|
Show full unit code |
Letter G = G
#65 = A
Control character
Chr(66) = B
Char(67) = C
|
|