[fpc-devel] SysUtils.GetEnvironmentVariable(String) still uses GetEnvironmentVariableA

Denis Kozlov dezlov at gmail.com
Mon May 23 19:31:18 CEST 2016


On 23 May 2016 at 15:23, Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:

>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160523/dbd16fcd/attachment.html>


More information about the fpc-devel mailing list