No, it is simply not possible to pass a string as TSysCharSet.
However, you can create a TSysCharSet that contains all the characters in the string. This code will do this:
var
AValidChars: SysUtils.TSysCharSet;
s: AnsiString;
i: integer;
begin
// Edit1.Text can contain 0..9 or a..z
AValidChars := [];
s := Edit1.Text;
for i := 1 to Length(s) do
Include(AValidChars, s[i]);
end;
If you are not using an earlier version of Delphi, you can also use "for ... in" instead of the loop above:
var
AValidChars: SysUtils.TSysCharSet;
c: AnsiChar;
begin
AValidChars := [];
for c in Edit1.Text do
Include(AValidChars, c);
end;
Note that both code snippets use AnsiString / AnsiChar, since this method will not work with WideString or the Unicode string type introduced with Delphi 2009.
Craig Stuntz, Ken White , , .