http://fundementals.sourceforge.net/cUnicode.html
例如使用 WidePos 就可以進行 Pos 的 widestring 版本. 相當值得參考的一篇文章.
代碼: 選擇全部
function WidePMatch(const M: WideString; const P: PWideChar): Boolean;
var I, L : Integer;
Q, R : PWideChar;
begin
L := Length(M);
if L = 0 then
begin
Result := False;
exit;
end;
R := Pointer(M);
Q := P;
For I := 1 to L do
if R^ <> Q^ then
begin
Result := False;
exit;
end else
begin
Inc(R);
Inc(Q);
end;
Result := True;
end;
function WidePos(const F: WideString; const S: WideString; const StartIndex: Integer=1): Integer;
var P : PWideChar;
I, L : Integer;
begin
L := Length(S);
if (StartIndex > L) or (StartIndex < 1) then
begin
Result := 0;
exit;
end;
P := Pointer(S);
Inc(P, StartIndex - 1);
For I := StartIndex to L do
if WidePMatch(F, P) then
begin
Result := I;
exit;
end
else
Inc(P);
Result := 0;
end;