索引是System.Character
通过调用来提高的CheckZeroStringRange
。相关定义:
resourcestring
sArgumentOutOfRange_StringIndex =
'String index out of range (%d). Must be >= %d and <= %d';
class procedure TCharHelper.RaiseCheckStringRangeException(Index, LowIndex,
MaxIndex: Integer);
begin
raise EArgumentOutOfRangeException.CreateResFmt(@sArgumentOutOfRange_StringIndex,
[Index, LowIndex, MaxIndex]) at ReturnAddress;
end;
procedure CheckZeroStringRange(const S: string; Index: Integer); inline;
var
MaxIndex: Integer;
begin
MaxIndex := High(S);
if (Index > MaxIndex) or (Index < 0) then
Char.RaiseCheckStringRangeException(index, 0, MaxIndex);
end;
现在您的错误表明您的代码正在尝试访问长度为 1、索引为 -1 的从零开始的字符串。这就是你的错误信息告诉你的。
有 20 次调用CheckZeroStringRange
in System.Character
。它们都非常相似,看起来像这样:
class function TCharHelper.IsDigit(const S: string; Index: Integer): Boolean;
var
C: UCS4Char;
begin
CheckZeroStringRange(S, Index);
C := UCS4Char(S[Index]);
if IsLatin1(C) then
Result := C in [$0030..$0039] // '0' / '9'
else
Result := InternalGetUnicodeCategory(ConvertToUtf32(S, Index)) =
TUnicodeCategory.ucDecimalNumber;
end;
因此,您的程序中的某些内容正在发出如下所示的调用:
if TCharHelper.IsDigit(str, -1) then // BOOM!
当然,它不会完全像这样,但这是我们所能辨别的。
下一步是进行一些调试。如果您不能直接在设备上调试,则需要在程序中添加一些跟踪日志,以识别导致错误的调用序列。缺陷可能存在于您的代码中,也可能存在于 Delphi 库代码中,也可能存在于您使用的某些第三方代码中。同样,我们不能说。
鉴于您在问题中提出的事实,我认为无法提供更多信息。