mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 20:59:12 +02:00
win32: fix WideChar -> UTF8 conversion in GetLocaleStr with fpc 2.6.4. Issue #31272. Patch by Luca Olivetti
git-svn-id: trunk@54005 -
This commit is contained in:
parent
076beac6c5
commit
bb1a32ecba
@ -348,7 +348,7 @@ end;
|
|||||||
|
|
||||||
function GetLocaleStr(aLocaleID, aLCType: Longint; const Def: string): String;
|
function GetLocaleStr(aLocaleID, aLCType: Longint; const Def: string): String;
|
||||||
var
|
var
|
||||||
L: Integer;
|
L, ResultLen: Integer;
|
||||||
Buf: array[0..255] of WideChar;
|
Buf: array[0..255] of WideChar;
|
||||||
begin
|
begin
|
||||||
L := GetLocaleInfoW(aLocaleID, aLCType, Buf, SizeOf(Buf));
|
L := GetLocaleInfoW(aLocaleID, aLCType, Buf, SizeOf(Buf));
|
||||||
@ -358,7 +358,14 @@ begin
|
|||||||
{$IF FPC_FULLVERSION >= 30000}
|
{$IF FPC_FULLVERSION >= 30000}
|
||||||
widestringmanager.Wide2AnsiMoveProc(PWideChar(@Buf[0]),Result,CP_UTF8,L-1);
|
widestringmanager.Wide2AnsiMoveProc(PWideChar(@Buf[0]),Result,CP_UTF8,L-1);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
widestringmanager.Wide2AnsiMoveProc(PWideChar(@Buf[0]),Result,CP_UTF8);
|
ResultLen:=WideCharToMultiByte(CP_UTF8,0,PWideChar(@Buf[0]),L-1,nil,0,nil,nil);
|
||||||
|
if ResultLen > 0 then
|
||||||
|
begin
|
||||||
|
SetLength(Result,ResultLen);
|
||||||
|
WideCharToMultiByte(CP_UTF8,0,PWideChar(@Buf[0]),L-1,@result[1],ResultLen,nil,nil)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result:=Def;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user