Delphi中简体中文与繁体中文的转换函数
简体中文与繁体中文的转换函数function GB2Big(GB: string ): string;var
Len: Integer;
begin
Len := Length(GB);
SetLength(Result, Len);
LCMapString(GetUserDefaultLCID, LCMAP_TRADITIONAL_CHINESE, PChar(GB), Len, PChar(Result), Len);
end;
function Big2GB(Big: string ): string;
var
Len: Integer;
begin
Len := Length(Big);
SetLength(Result, Len);
LCMapString(GetUserDefaultLCID, LCMAP_SIMPLIFIED_CHINESE, PChar(Big), Len, PChar(Result), Len);
end;汉字与 Unicode 转换函数
{感谢 robin(xuebin418@163.com)提供}//转换
function Str_Gb2UniCode(text: string): String;
var
i,len: Integer;
cur: Integer;
t: String;
ws: WideString;
begin
Result := '';
ws := text;
len := Length(ws);
i := 1;
while i <= len do
begin
cur := Ord(ws);
FmtStr(t,'%4.4X',);
Result := Result + t;
Inc(i);
end;
end;
//恢复
function Unicode_str(text: string):string;
var
i,len: Integer;
ws: WideString;
begin
ws := '';
i := 1;
len := Length(text);
while i < len do
begin
ws := ws + Widechar(StrToInt('$' + Copy(text,i,4)));
i := i+4;
end;
Result := ws;
end;
//测试
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(Str_Gb2UniCode('万一'));//4E074E00
ShowMessage(Unicode_str('4E074E00'));//万一
end;
页:
[1]