* don't truncate environment variable strings in GetEnvironmentString()

* set the correct code page for the result of GetEnvironmentString() on
    Windows and NativeNT

git-svn-id: branches/cpstrrtl@25103 -
This commit is contained in:
Jonas Maebe 2013-07-15 09:21:20 +00:00
parent 08099c8558
commit 8b77f62873
3 changed files with 14 additions and 10 deletions

View File

@ -1108,6 +1108,7 @@ begin
len:=UnicodeToUTF8(Nil, hp, 0);
SetLength(Result, len);
UnicodeToUTF8(PChar(Result), hp, len);
SetCodePage(RawByteString(Result),CP_UTF8,false);
end;
end;
end;

View File

@ -66,11 +66,11 @@ begin
Result:='';
while assigned(EP^) and (Index>1) do
begin
Dec(Index);
inc(EP);
dec(Index);
inc(EP);
end;
If Assigned(EP^) then
Result:=StrPas(EP^);
if Assigned(EP^) then
Result:=EP^;
end;

View File

@ -1026,13 +1026,16 @@ begin
hp:=p;
If (Hp<>Nil) then
begin
while (hp^<>#0) and (Index>1) do
begin
Dec(Index);
hp:=hp+strlen(hp)+1;
end;
while (hp^<>#0) and (Index>1) do
begin
Dec(Index);
hp:=hp+strlen(hp)+1;
end;
If (hp^<>#0) then
Result:=StrPas(HP);
begin
Result:=HP;
SetCodePage(RawByteString(Result),CP_OEMCP,false);
end;
end;
FreeEnvironmentStringsA(p);
end;