function SToT(SStr: string): string; var Str1, TStr: string; i: Integer; Flag: Boolean; begin Flag := false; Str1 := ''; TStr := ''; Result := ''; if Not tbST.Active then tbST.Open; if Length(SStr)>0 then begin for i := 1 to Length(SStr) do begin if flag then Flag := false else begin if IsDBCSLeadByte(byte(SStr[i])) then begin Str1 := SStr[i] + SStr[i+1]; if tbST.Locate('S', Str1,[]) then begin TStr := tbST.FieldByName('T').asstring;// end else TStr := Str1; Result := Result + TStr; Flag := true; end else begin Result := Result + SStr[i]; end; end; end; end; end;
var
Str1, TStr: string;
i: Integer;
Flag: Boolean;
begin
Flag := false;
Str1 := '';
TStr := '';
Result := '';
if Not tbST.Active then
tbST.Open;
if Length(SStr)>0 then
begin
for i := 1 to Length(SStr) do
begin
if flag then
Flag := false
else begin
if IsDBCSLeadByte(byte(SStr[i])) then
begin
Str1 := SStr[i] + SStr[i+1];
if tbST.Locate('S', Str1,[]) then
begin
TStr := tbST.FieldByName('T').asstring;//
end else
TStr := Str1;
Result := Result + TStr;
Flag := true;
end
else begin
Result := Result + SStr[i];
end;
end;
end;
end;
end;
8222213(蹂躏Delphi)
等上面的共享目录上都有代码,不过是Delphi代码,暂时未转成存储过程。
为防止病毒,使用前请自己编译。
然后用IsDBCSLeadByte来判断是否要转换,然后从表中取得对应的简/繁体