hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

Sys.programPath retruns empty string on Windows, when `disable_unicode_strings` is defined

Open ntrf opened this issue 5 years ago • 0 comments

I'm compiling Win32 builds with MSVS 2013 express. I had to disable unicode strings, because changing compiler is not possible for me at the moment and latest hxcpp runtime requires some of the C++11 features, not implemented by MSVS 2013 compiler.

Either way this bug i've discovered is not related to MSVS or haxe compiler. When Sys.programPath is called, result returned by GetModuleFileNameW is encoded in UTF-8. It's then converted to UTF-8 with a call of String::create, but with ony one argument. A second argument is assigned to default value of -1, however internal function TConvertToUTF8 treats such input as empty string, instead of zero-terminated string. TConvertToUTF8 expects this parametr to be 0 in order to replace it with the length of the string.

One of two things need to be done to fix this:

  1. Default value of parameter inLen of function String::create should be changed to 0, or
  2. TConvertToUTF8 should treat value -1 of string length as zero-terminated string.

Or you can, obviously declare the whole thing deprecated, in which case you should at least print some kind of warning.

ntrf avatar Sep 15 '19 14:09 ntrf