I have an working Pascal scripts for Inno Setup, but recently we ran into an issue with Unicode characters. And after changing the Inno Setup to Unicode version we got errors in existing scripts. And this error is too generic - "Type mismatch" for certain line. Since our main script is composed of lots of other scripts that are included I'm not sure if that line is the correct, and it points to this function below, and line with Set of Char
.
After looking the Inno Setup documentation I found that Unicode version is bit more strict about some things, and also there was some changes around ANSI string handling (and probably Char
as well).
function IsValidName(Name: String):String;
var
Valid_Ch: Set of Char;
Location: Integer;
begin
Valid_Ch := ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '_', '-'];
Result := '';
for Location := 1 to Length(Name) do
begin
if Name[Location] in Valid_Ch then
begin
Result := Result + Name[Location];
end
else
begin
Result := Result + '_';
end;
end;
end;
This all looks fine to me, but this is my first touch with Pascal. I would be thankful if someone more experienced could help me about this. Thanks!