delphi7调用delphi2009生成的dll文件会出现乱码问题。是unicode的原因
终于从爱点delphi中找到了转换函数
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;
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;
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。