Skip to content

Invalid unicode string from file dialogue on non-Windows system #1622

@tobil4sk

Description

@tobil4sk

When using the save file dialogue on non-Windows systems, any non-ASCII characters in the file name result in an invalid string. This is because the string is returned as a wstring: https://github.com/openfl/lime/blob/develop/project/src/ExternalInterface.cpp#L902

While this works fine on Windows, this is problematic on Linux where wstring is not standard. As a result, if the string ends up being passed to hxcpp's system functions, it is considered invalid and we end up with confusing error messages (like Allocating from a GC-free thread which comes from a failed allocation of an exception string to describe this issue).

It's possible to workaround this issue by adding an extra conversion back to a regular string: develop...tobil4sk:lime:74eefc47a480f8055796310f8f3cd770a00b7b16

However, it would probably be better to refactor the api a bit to remove the need for wstring on non Windows systems altogether, because right now there are redundant conversions between string types just to fit this api:

Conversion to wstring:

std::wstring* _title = hxstring_to_wstring (title);
std::wstring* _filter = hxstring_to_wstring (filter);
std::wstring* _defaultPath = hxstring_to_wstring (defaultPath);

Conversion from wstring to string:
std::string* _title = wstring_to_string (title);
std::string* _filter = wstring_to_string (filter);
std::string* _defaultPath = wstring_to_string (defaultPath);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions