UpCase Function
The UpCase
function converts an ASCII character to
uppercase. If C
is not a lowercase character,
UpCase
returns C
.
UpCase
is a real
function.
UpCase
does not handle international
characters—it handles only “a” through
“z”.
Delphi does not have a corresponding DownCase
function.
function DownCase(Ch: Char): Char;
begin
if Ch in ['A'..'Z'] then
Result := Chr(Ord(Ch) - Ord('A') + Ord('a'))
else
Result := Ch;
end;
// Convert an identifier to canonical form, i.e., initial uppercase
// character followed by all lower case characters.
function Canonical(const S: string): string;
var
I: Integer;
begin
SetLength(Result, Length(S));
if Length(S) > 0 then
Result[1] := UpCase(S[1]);
for I := 2 to Length(S) do
Result[I] := DownCase(S[I]);
end;