Here is another question about convert old code to D2009 and Unicode. I’m certain that there is simple but i don’t see the solution…
CharacterSet is a set of Char and s[i] should also be a Char.
But the compiler still think there is a conflict between AnsiChar and Char.
The code:
TSetOfChar = Set of Char;
procedure aFunc;
var
CharacterSet: TSetOfChar;
s: String;
j: Integer;
CaseSensitive: Boolean;
begin
// Other code that assign a string to s
// Set CaseSensitive to a value
CharacterSet := [];
for j := 1 to Length(s) do
begin
Include(CharacterSet, s[j]); // E2010 Incompatible types: 'AnsiChar' and 'Char'
if not CaseSensitive then
begin
Include(CharacterSet, AnsiUpperCase(s[j])[1]);
Include(CharacterSet, AnsiLowerCase(s[j])[1])
end
end;
end;
There is no good and simple answer to the question (the reason is already given by Mason). The good solution is to reconsider the algoritm to get rid off “set of char” type. The quick and dirty solution is to preserve ansi chars and strings: