まず、文字列との間の変換は避けます。直接比較するだけsPassword[nCount]
です。127
InstallScript はワイド文字 (16 ビットの数値) を格納します。
別の方法として、US-ASCIIコード ページ(20127)を使用してWideCharToMultiByteを呼び出すこともできます。私は InstallScript にそれほど強くなく、コンパイラーを使用せずにコーディングしているため、エラーを 1 つか 2 つ修正する必要があるかもしれませんが、大まかなアイデアは次のとおりです。
#define CP_US_ASCII 20127
extern prototype NUMBER Kernel32.WideCharToMultiByte(NUMBER, NUMBER, WSTRING, NUMBER, STRING, NUMBER, STRING, BYREF BOOL);
function BOOL IsSafeAscii(STRING szCheck)
STRING szOut;
BOOL bReplaced;
begin
WideCharToMultiBute(CP_US_ASCII, // only supports characters 0-127
WC_NO_BEST_FIT_CHARS, // or maybe 0; disallow turning accented to plain
szCheck, // test string
StrLength(szCheck), // length of test string
szOut, // return buffer
StrLength(szOut), // length of return buffer
"?", // replacement for unsupported characters
bReplaced); // whether replacement was used
return !bReplaced;
end;