Are you sure, it is the environment, and not the console to which you write.
Below code prints the ord values for each char, and they seem to be correct.
As I do not have none-latin chars in my path, I went to
menu: Run > Run parameters
and set an env variable
test1=Игорь
test2=äöü
Note the app below also prints the utf8 as ordinals. Windows of course does not return utf8.
It either returns utf16, or the local codepage (My local codepage has no support for Игорь , hence the äöü)
All instances of Игорь print
1048, 1075, 1086, 1088, 1100,
That is the same under an IDE build with fpc 3.0.4 and 3.2.0
That seems correct according to 1048 = 0x418
https://www.compart.com/en/unicode/U+0418program project1;
{$codepage utf8}
{$mode objfpc}{$H+}
uses
windows
;
{$R *.res}
function ExpandEnvironmentStringsW(lpSrc: PWideChar; lpDst: PWideChar;
nSize: Cardinal): Cardinal; stdcall; external 'kernel32.dll' name 'ExpandEnvironmentStringsW';
function GetEnv(const Name: WideString): WideString;
var
len : Cardinal;
begin
len:=ExpandEnvironmentStringsW( PWideChar(Name), nil, 0);
if len>0 then begin
SetLength( Result, len-1 );
ExpandEnvironmentStringsW( PWideChar(Name), PWideChar(Result), len );
end else Result:='';
end;
procedure Test(const Name : WideString);
var
w: WideChar;
begin
WriteLn( 'EvnVar '+Name,' = ', GetEnv(Name) );
for w in GetEnv(Name) do
write(ord(w), ', ');
writeln;
end;
const
t1: widestring = widestring('Игорь');
t2: UTF8String = 'Игорь';
d1: widestring = widestring('äöü');
d2: UTF8String = 'äöü';
var
x: array [0..101] of word;
y: array [0..101] of byte;
i: Integer;
l: DWORD;
w: WideChar;
c: Char;
begin
for w in t1 do
write(ord(w), ', ');
writeln;
for c in t2 do
write(ord(c), ', ');
writeln;
writeln;
l := GetEnvironmentVariableW(pwidechar('test1'), @x[0], 100);
writeln(l);
for i := 0 to l-1 do
write(x[i],', ');
writeln;
l := GetEnvironmentVariableA(pchar('test1'), @y[0], 100);
writeln(l);
for i := 0 to l-1 do
write(y[i],', ');
writeln;
writeln;
writeln;
writeln;
for w in d1 do
write(ord(w), ', ');
writeln;
for c in d2 do
write(ord(c), ', ');
writeln;
writeln;
l := GetEnvironmentVariableW(pwidechar('test2'), @x[0], 100);
writeln(l);
for i := 0 to l-1 do
write(x[i],', ');
writeln;
l := GetEnvironmentVariableA(pchar('test2'), @y[0], 100);
writeln(l);
for i := 0 to l-1 do
write(y[i],', ');
writeln;
Test('%test1%'); WriteLn;
Test('%test2%'); WriteLn;
readln;
end.