var a:string;
a:='见';
//现在需要把这个字符串'活见鬼'转化成繁体来显示
转化后的结果为:
a:='見';
a:='见';
//现在需要把这个字符串'活见鬼'转化成繁体来显示
转化后的结果为:
a:='見';
解决方案 »
- DELPHI7 伸缩窗体问题~!
- delphi 运行出现如下错误,确定后光标指在SQL.Clear;
- 关于DELPHI 写内存 请求大家帮忙 在线等哦
- 高手请帮忙, 关于cxTreeList的问题
- 调用VC写的dll,为什么同一个函数重复调用两次时出错(一次正常)...
- 为什么往ADoquery中添加一条记录会出错,能不能帮我分析一下原因?
- 如何把 richedit 的文字和文字格式保存在指定文件中?
- (在线等待.....初程问题)1.如何调用ListBox的双击事件!2.operdioge控件如何能进行多选,早回早得!
- 一个关于writebuffer的问题!在线等待,送分
- 又在深圳的Delphi程序员吗?-->请进
- 关闭子窗体问题
- 计算机重启
interface
function GBtoBIG5(value: string): string;
function BIG5toGB(value: string): string;implementationvar
BIG5Order: array[0..14757] of Word;
GBOrder : array[0..8177] of Word;function GBOffset(value: string): integer;
begin
if length(value) >= 2 then
Result := (Ord(value[1]) - 161) * 94 + (Ord(value[2]) - 161)
else
Result := -1;
end;function BIG5Offset(value: string): integer;
begin
Result := -1;
if length(value) >= 2 then
begin
if (Ord(value[2]) >= 64) and (Ord(value[2]) <= 126) then
Result := (Ord(value[1]) - 161) * 157 + (Ord(value[2]) - 64);
if (Ord(value[2]) >= 161) and (Ord(value[2]) <= 254) then
Result := (Ord(value[1]) - 161) * 157 + 63 + (Ord(value[2]) - 161);
end
end;function WordToString(value: Word): string;
begin
Result := Chr(Hi(value)) + Chr(Lo(Value));
end;function isBIG5(value: string): Boolean;
begin
if (length(value)>=2) then
begin
if (value[1] < #161) then
Result := false
else
if ((value[2] >= #64) and (value[2] <= #126)) or ((value[2] >= #161) and (value[2] <= #254)) then
Result := true
else
Result := false
end
else
Result := false
end;function isGB(value: string): Boolean;
begin
if (length(value)>=2) then
begin
if (value[1] <= #161) and (value[1] >= #247) then
Result := false
else
if (value[2] <= #161) and (value[2] >= #254) then
Result := false
else
Result := true
end
else
Result := true;
end;function GBtoBIG5(value: string): string;
var
leng, idx : integer;
tmpStr : string[2];
Offset : integer;
output : string;
begin
output := '';
leng := length(value);
idx := 1;
while idx <= leng do
begin
tmpStr := value[idx]+ value[idx + 1];
if isGB(tmpStr) then
begin
offset:=GBOffset(tmpStr);
if (offset >= 0) and (offset <= 8177) then
begin
output := output + WordToString(GBOrder[offset]);
inc(idx);
end
else
output := output + value[idx] ;
end
else
output := output + value[idx] ; inc(idx, 1);
end;
Result := output;
end;function BIG5toGB(value: string): string;
var
leng, idx : integer;
tmpStr : string[2];
output : string;
offset : integer;
begin
output := '';
leng := length(value);
idx := 1;
while idx <= leng do
begin
tmpStr := value[idx]+ value[idx + 1];
if isBIG5(tmpStr) then
begin
offset:=BIG5Offset(tmpStr);
if (offset >= 0) and (offset <= 14757) then
begin
output := output + WordToString(BIG5Order[offset]);
inc(idx);
end
else
output := output + value[idx];
end
else
output := output + value[idx]; inc(idx);
end;
Result := output;
end;
GBK? Big5? Unicode?