windows installer: convert installer translation strings from UTF8 to the system char set (#9959)

git-svn-id: trunk@12627 -
This commit is contained in:
vincents 2007-10-29 13:34:42 +00:00
parent b00ad25a27
commit c93109da6a

View File

@ -239,6 +239,56 @@ begin
end;
end;
function MultiByteToWideChar(CodePage, dwFlags: cardinal; lpMultiByteStr: PChar;
cbMultiByte: integer; lpWideCharStr: PChar; cchWideChar: integer) : integer;
EXTERNAL 'MultiByteToWideChar@kernel32.dll stdcall';
function WideCharToMultiByte(CodePage, dwFlags: cardinal; lpWideCharStr: PChar;
cchWideChar: integer; lpMultiByteStr: PChar; cbMultiByte: integer;
lpDefaultChar: integer; lpUsedDefaultChar: integer): integer;
EXTERNAL 'WideCharToMultiByte@kernel32.dll stdcall';
function GetLastError: DWord;
EXTERNAL 'GetLastError@kernel32.dll stdcall';
const
CP_ACP = 0;
CP_UTF8 = 65001;
function DumpString(const s: string): string;
var
i: integer;
begin
Result := '';
for i := 1 to length(s) do
result := result + '#' + IntToStr(ord(s[i]));
end;
function ConvertUTF8ToSystemCharSet(const UTF8String: string): string;
var
UTF8Length: integer;
UCS2String : string;
SystemCharSetString: string;
ResultLength: integer;
Result2: integer;
begin
MsgBox('UTF8String: ' + UTF8String + ' / ' + DumpString(UTF8String), mbInformation, MB_OK );
UTF8Length := length(UTF8String);
// this is certainly long enough
SetLength(UCS2String, length(UTF8String)*2+1);
Result2 := MultiByteToWideChar(CP_UTF8, 0,
PChar(UTF8String), -1, PChar(UCS2String), UTF8Length + 1);
//MsgBox('Result2: ' + IntToStr(Result2), mbInformation, MB_OK );
if (Result2=0) then
MsgBox('GetLastError: ' + IntToStr(GetLastError), mbInformation, MB_OK );
MsgBox('UCS2String: ' + DumpString(UCS2String), mbInformation, MB_OK );
SetLength(SystemCharSetString, Length(UTF8String));
ResultLength := WideCharToMultiByte(CP_ACP, 0, PChar(UCS2String), -1,
PChar(SystemCharSetString), Length(SystemCharSetString)+1, 0, 0) -1;
Result := copy(SystemCharSetString, 1, ResultLength);
MsgBox('Result: ' + Result + ' / ' + DumpString(Result), mbInformation, MB_OK );
end;
function GetPoString(const msgid: string): string;
var
Signature: string;
@ -260,6 +310,7 @@ begin
if Result='' then
Result := copy(PoFileStrings[i+1],8, Length(PoFileStrings[i+1])-8);
end;
Result := ConvertUTF8ToSystemCharSet(Result);
end;
function GetAssociateDesc(const ext: string): string;