function WideCharToChnByte(ws:pbyte; var s:String):Integer;
var
l : integer;
begin
l := WideCharToMultiByte(936,0,PWideChar(ws),-1,nil,0,nil,0)-1;
setlength(s,l);
WideCharToMultiByte(936,0,PWideChar(ws),-1,@s[1],l,nil,0);
result := l;
end;
function chnByteToWideChar(s:pbyte; var ws:WideString):Integer;
var
l : integer;
begin
l := MultiByteToWideChar(936,0,PChar(s),-1,nil,0)-1;
setlength(ws,l);
MultiByteToWideChar(936,0,pchar(s),-1,@ws[1],l);
result := l;
end;
function toUNICODE(s:string):WideString;
begin
chnByteToWideChar(@s[1],result);
end;
function toCHINESE(ws:WideString):string;
begin
WideCharToChnByte(@ws[1], Result);
end; |
¡¡ |