此处所列的文章均是我自己从国外的网站摘抄并翻译的,由于英文水平有限,里面肯定有不少错漏.翻译这些东西没有其他的什么用途,只是提高自己的英语阅读能力和编程技术水平而已     

字符串函数

function XXXCompareText(const S1, S2: string): Integer;
Begin
  Result := CompareString(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, Pchar(s1), Length(s1), Pchar(s2), Length(s2)) - 2;
end;

function XXXSameStr(const S1, S2: string): Boolean;
begin
  Result := XXXCompareText(S1, S2) = 0;
end;

 

 

function AnsiIndexStr(const AText: string;
  const AValues: array of string): Integer;
var
  i: Integer;
Begin
  Result := -1;
  for i := low(AValues) to high(AValues) do
  Begin
    if  XXXSameStr(AText, AValues[i]) then
    Begin
      Result := I;
      break;
    end;
  end;
end;

function AnsiStrComp(S1, S2: String): Integer;
begin
  Result := CompareString(LOCALE_USER_DEFAULT, 0, Pchar(s1), -1, Pchar(s2), -1) - 2;
end;

 

function XXXIndexStr(const AText: string;
  const AValues: array of string): Integer;
var
  i: Integer;
Begin
  Result := -1;
  for i := low(AValues) to high(AValues) do
  Begin
    if  XXXSameStr(AText, AValues[i]) then
    Begin
      Result := I;
      break;
    end;
  end;
end;

function XXXMatchStr(const AText: string;
  const AValues: array of string): Boolean;
begin
  Result := XXXIndexStr(AText, AValues) <> -1;
end;

function AnsiStrComp(S1, S2: String): Integer;
begin
  Result := CompareString(LOCALE_USER_DEFAULT, 0, Pchar(s1), -1, Pchar(s2), -1) - 2;
end;

posted @ 2010-11-07 20:39  AppleAndPear  阅读(132)  评论(0编辑  收藏  举报