COMMUNITY

$50 bounty -- Unicode-aware windows file operations for hxcpp (time sensitive!)

Hey everyone!

I have a bit of a time sensitive need to get a quick patch to get unicode-aware file system operations working with hxcpp/windows.

Some of you might remember this post:
https://groups.google.com/forum/?hl=en#!searchin/haxelang/wchar|sort:date/haxelang/IV2LXHJwjqQ/n0JDszqyAwAJ

Apparently, despite some patches being upstreamed since then, with the latest hxcpp/haxe this still seems to be an issue. You can verify yourself with this code:

FileSystem.createDirectory("C:\\Денис");
File.saveContent("C:\\Денис\\test.txt", "Денис");

The expected result is you’ll get a folder at the path “C:\Денис” with the contents “Денис”. Instead you’ll get a folder at the path “C:<garbage>” with the contents “Денис”. It seems the issue is passing a string to the windows file system operations.

I’m about to have an influx of Korean and Chinese users tomorrow, and I just discovered I still am suffering from this bug, and I know I’m going to get a lot of bug reports if I can’t get a quick fix in.

I found a promising lead in this library:

But it’s neko-only, and I’m not familiar with the build system that he’s using in order to attempt recompiling it for hxcpp/windows. If you know how to rejigger it to work with C++ / CFFI and hxccp/windows in the next 12 hours, I’m happy to pay a $50 bounty immediately.

I used to deal with Chinese in hxcpp, maybe this gist helps. But it depends on the local environment. Because it uses setlocale(LC_CTYPE, "")

example:

FileSystem.createDirectory(Mbs.utf8tombs("C:\\Денис"));
File.saveContent(Mbs.utf8tombs("C:\\Денис\\test.txt"), "Денис");
1 Like

I will try it right away, thanks very much!

I just tried this, and unfortunately it does not work for me – it still creates a garbage directory (I tried to post the exact characters but I think it tripped up discourse’s spam filter :P).

Maybe this is because of the local environment dependency you mentioned?

I only tested it on win7-32bit, maybe you should looking for a russian guy to help you…

Well, for what it’s worth I’ve had this issue with korean, japanese, and chinese text, too. It originally manifested with a korean player.

Update, here’s an attempt to monkey-patch hxcpp’s std library Sys.cpp file:

Seems to work, but testing now.

Thanks to @MJKlaim and @DougBinks on twitter

UPDATE:
I can create the directory now, but I still can’t write to a file with a unicode path.

Joshua Granick made a commit that looks like it fixes it (just tested, confirmed)

@MJKlaim turned down the bounty but I’m happy to pay out $50 each to both Joshua and Doug here

1 Like

I am somewhat confused to see a NEKO_WINDOWS flag that also seem to be used when building for C++ & Windows (thus not neko directly), but I guess I am missing something.

Anyway good news for the fix! Especially that other developers (like me) could have hit the same problem in the future, so thank you!