I converting a lecacy app from Delphi 7 to Delphi 2009.
I got this error: E2010 Incompatible types: 'Char' and 'AnsiChar'
How can I fix it ? I tried to declare Alphabet: Ansistring[AlphabetLength] but that failed.
const
AlphabetLength = 64;
Alphabet: string[AlphabetLength] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
function TBase64.ValueToCharacter(value: Byte; var character: char): boolean;
begin
Result := true;
if (value > AlphabetLength-1) then
Result := false
else
// Compile error E2010 Incompatible types: 'Char' and 'AnsiChar'
character := Alphabet[value+1];
end;
function TBase64.CharacterToValue(character: char; var value: byte): boolean;
begin
Result := true;
value := Pos(character, Alphabet);
if value = 0 then
Result := false
else
value := value-1;
end;
Best Answer
Avoid using the deprecated ShortString type in Unicode Delphi versions (2009 and later):
the above change should be enough. You must also think about changing from 1-byte AnsiChars to 2-byte Chars.
edit (jeroen pluimers):
Here is some documentation on the string types.