Jonas Maebe wrote 18 lines
Michael Van Canneyt wrote on Mon, 23 May 2016:
The typecase will not help you, since the result is an ansistring.
> The result will still be crippled.
>
It would help when DefaultSystemCodePage is changed to UTF-8, as Lazarus
does.
The only solution for this is a unicode RTL.
>
That is incorrect, since as he wrote the unicodestring version of
GetEnvironmentVariable() already exists in our RTL today. It's just that
it's only used if you pass it a unicodestring argument, which won't be be
the case in most Lazarus programs by default.
So, do we agree that it would be beneficial to change SysUtils.GetEnvironmentVariable(String) to call the UnicodeString overload internally?
function GetEnvironmentVariable(const EnvVar: String): String;
begin
Result := String(GetEnvironmentVariable(UnicodeString(EnvVar)));
end;
This would propagate to GetEnvironmentVariableUTF8 in Lazarus, where a ConsoleToUTF8 conversion should then be removed.
SysUtils.GetEnvironmentString(Integer) and
SysUtils.GetEnvironmentVariableCount() also call crippled GetEnvironmentStringsA.
Denis