haxe icon indicating copy to clipboard operation
haxe copied to clipboard

[CPP] `Sys.getCwd()` returns wrong path if the path contains non-ascii chars

Open T1mL3arn opened this issue 1 year ago • 2 comments

Following this openfl/lime/issues/1757 issue, I though I found a workaround, but it didn't work for cpp.

So, Lime structures get incorrect path to assets and the app crashes. Using Sys.getCwd() to get the correct path worked for my case only on HL. Trying it on cpp I still get the crash - non-ascii path results with wrong string returned by Sys.getCwd().

trace(Sys.getCwd());

what it should be

C:\game\export\windows\я\

but it is

C:\game\export\windows\╤П\

As was stated in similar issue #10859, tediously telling the users how to "properly start" the app is annoying.

T1mL3arn avatar Feb 06 '24 05:02 T1mL3arn

Are you sure the problem is with Sys.getCwd()? I've run into similar issues where the strings returned from system functions were correct, but they were printed incorrectly:

https://github.com/HaxeFoundation/hxcpp/pull/880

Maybe test:

trace("C:\\game\\export\\windows\\я\\");
trace(Sys.getCwd());
trace(Sys.getCwd() == "C:\\game\\export\\windows\\я\\");

tobil4sk avatar Feb 06 '24 10:02 tobil4sk

Thanks for pointing this. Indeed comparison (slightly changed though) returns true

trace("C:\\game\\export\\windows\\я");
trace(Sys.getCwd());
trace(Sys.getCwd() == "C:\\game\\export\\windows\\я/");
src/Main.hx:15: C:\game\export\windows\С'
src/Main.hx:16: C:\game\export\windows\С'/
src/Main.hx:17: true

I will do more tests with Lime then.

T1mL3arn avatar Feb 06 '24 12:02 T1mL3arn