ansistring-->unionstring 怪码

function Tpublicf.PKHisDo(inStr: string; var OutStr: string): Integer;
var
JG: PWideChar;
sinstr: PWideChar;
begin
GetMem(JG, 2048);
GetMem(sinstr, 2048);
try
sinstr := PWideChar(AnsiToUnicode(inStr));
Result := HISDO(sinstr, JG);
OutStr := Trim(UnicodeToAnsi(JG));
finally
FreeMem(JG);
// FreeMem(sinstr);
end;

end;

 


function UnicodeToAnsi(s: WideString): string;
var
lpChar: PChar;
len: integer;
begin
len := Length(s) * 2;
GetMem(lpChar, len);
ZeroMemory(lpChar, len);
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, PWideChar(s), Length(s), lpChar, len, nil, nil);
Result := lpChar;
FreeMem(lpChar);
end;

function AnsiToUnicode(s: string): WideString;
var
lpWideChar: PWideChar;
len: Integer;
begin
len := (Length(s) + 1) * 2;
GetMem(lpWideChar, len);
ZeroMemory(lpWideChar, len);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, PChar(s), Length(s), lpWideChar, len);
Result := lpWideChar;
FreeMem(lpWideChar);
end;

posted @ 2018-03-18 14:12  绿水青山777  阅读(148)  评论(0编辑  收藏  举报