2个回答
展开全部
//unicode转字ASC
function U2GB(Str: string): string;
var
s: pchar;
i: integer;
tmp: string;
begin
tmp := '';
result := '';
s := PChar(str);
i := 0;
while i < length(s) do
begin
tmp := tmp + chr(HexToInt(s[i + 2] + s[i + 3])) + chr(HexToInt(s[i] + s[i + 1]));//unicode转换时,高低位互换
inc(i, 4);
end;
result := widechartostring(pWideChar(tmp));
end;
//ASC转换成unicode
function EncodeUniCode(Str:WideString):string; //字符串->PDU
var
i,len:Integer;
cur:Integer;
begin
Result:='';
len:=Length(Str);
i:=1;
while i<=len do
begin
cur:=ord(Str[i]);
Result:=Result+IntToHex(Cur,4);
inc(i);
end;
end;
function U2GB(Str: string): string;
var
s: pchar;
i: integer;
tmp: string;
begin
tmp := '';
result := '';
s := PChar(str);
i := 0;
while i < length(s) do
begin
tmp := tmp + chr(HexToInt(s[i + 2] + s[i + 3])) + chr(HexToInt(s[i] + s[i + 1]));//unicode转换时,高低位互换
inc(i, 4);
end;
result := widechartostring(pWideChar(tmp));
end;
//ASC转换成unicode
function EncodeUniCode(Str:WideString):string; //字符串->PDU
var
i,len:Integer;
cur:Integer;
begin
Result:='';
len:=Length(Str);
i:=1;
while i<=len do
begin
cur:=ord(Str[i]);
Result:=Result+IntToHex(Cur,4);
inc(i);
end;
end;
来自:求助得到的回答
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询