请问哪有GB<-->BIG5码的转换控件(30分)

  • 主题发起人 主题发起人 waiwai
  • 开始时间 开始时间
你到vclxx.vcl.com上看看,我曾经见过一个.
 
从前在中国Borland程序员站点down过一个例子,改成控件很容易。
要的话我E给你。
 
我有一个,你要吗?


beta(mophy@188.net)
 
big5->gb

const

BIGfirst = $A140; // first code of BIG
BIGlast = $F9FE; // last code of BIG
BIGsize = $58BF; // BIGlast - BIGfirst + 1
function BIG5toGB(S: string): string;
var
bak : string;
C : array[0..1] of Byte;
I : Integer;
W : PWordArray;
CA : array[0..2] of Char;
begin
bak := '';
I := 1;
w:=@(C[0]);
while I <= Length(S) do
begin
C[1] := Byte(S);
if C[1] > $A0 then
begin
inc(I, 1);
C[0] := byte(S);
inc(I, 1);
W[0] := W[0] - BIGfirst;
BigTAB.Position:= W[0]*2;
BIGTAB.Read(CA,2);
CA[2]:=#0;
bak := bak + StrPas(CA);
end
else
begin
bak := bak + S;
inc(I, 1);
end;
end;
Result := bak;
end;

--------------------------------------------------
gb->big5
const
GBfirst = $A1A1; // first code of GB */
GBlast = $FEFE; //last code of GB */
GBsize = $5E5E; // GBlast - GBfirst + 1 */
GBTAB, DupCode, DupData: TResourceStream;

function GetBIGS(S: string): string;
var
C : array[0..5] of Char;
W : PWordArray;
CA : array[0..2] of Char;
I : Integer;
bak: string;
begin
bak := '';
if Byte(S[1]) > $A0 then
begin
W := @(C[0]);
C[2] := S[1];
C[3] := S[2];
C[5] := S[1];
C[4] := S[2];
W[2] := W[2] - GBfirst;
GBTAB.Position := W[2] * 2;
GBTAB.read (CA, 2);
CA[2] := #0;
bak := bak + StrPas(CA);
I := 0;
while I < DupCode.Size do
begin
DupCode.Position := I;
DupCode.read (C, 2);
if W[0] = W[1] then
begin
DupData.Position := I;
DupData.read (CA, 2);
CA[2] := #0;
bak := bak + CA;
end;
inc(I, 2);
end;
end;
Result := bak;
end;

function GBtoBIG5(S: string): string;
var
bak: string;
C : array[0..1] of Byte;
I : Integer;
W : PWordArray;
CA : array[0..2] of Char;
begin
bak := '';
W := @(C[0]);
I := 1;
while I <= Length(S) do
begin
C[1] := Byte(S);
if C[1] > $A0 then
begin
inc(I, 1);
C[0] := Byte(S);
inc(I, 1);
W[0] := W[0] - GBfirst;
GBTAB.Position := W[0] * 2;
GBTAB.read (CA, 2);
CA[2] := #0;
bak := bak + StrPas(CA);
end
else
begin
bak := bak + S;
inc(I, 1);
end;
end;
Result := bak;
end;
 
我email 给你了我的意见!
 
多人接受答案了。
 
后退
顶部