I'm try to port some code from D2007 to DXE2. This simplified code compiles fine in D2007. In DXE2 it show this error:
[DCC Warning] Unit1.pas(10): W1050 WideChar reduced to byte char in set expressions. Consider using 'CharInSet' function in 'SysUtils' unit.
[DCC Error] Unit1.pas(37): E2010 Incompatible types: 'AnsiChar' and 'Char'
Propably a unicode issue. Can someone tell me why this happen and how I should correct it ?
Regards
The code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TSetOfChar = Set of Char; // Line 10
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
FCharacterSet: TSetOfChar;
public
property CharacterSet: TSetOfChar read FCharacterSet write FCharacterSet;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
CharacterSet: TSetOfChar;
j: Integer;
s: String;
begin
CharacterSet := [];
s := 'I''m just testing åäö';
for j := 1 to Length(s) do
Include(CharacterSet, s[j]); // <- Line 37
end;
end.
EDIT: Note that I am using Delphi 2007 that have no generics. I want code that still works in D2007 because there is a lot of code to port to Unicode. This is slow process. When everything is ported, verified it works with XE2 then we can use XE2 things like generics. In the meantime we maintain the D2007 as usual and we want to avoid making a XE2 branch in the revision control system.