d7 ansi和unicode相互转换
Ansi转Unicode function AnsiToUnicode(Str: String): WideString; var LWideChar: PWideChar; Len: Integer; begin Len := (Length(Str) + 1) * 2; GetMem(LWideChar, Len); ZeroMemory(LWideChar, Len); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, PChar(Str), Length(Str), LWideChar, Len); Result := LWideChar; FreeMem(LWideChar); end;
Unicode转Ansi 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;