lime icon indicating copy to clipboard operation
lime copied to clipboard

UNICODE fixes (clipboard, window title, file dialogs, paths, font glyphs, ...)

Open nixbody opened this issue 4 years ago • 16 comments

Adds UNICODE support for CFFI related things on HXCPP and HashLink targets.

nixbody avatar Jul 29 '21 19:07 nixbody

Hey @restorer, can you take a look at this one and tell us how it compares to #1391?

player-03 avatar Apr 16 '23 18:04 player-03

@joshtynjala Can you resolve the conflicts in ExternalInterface.cpp? It looks like you were both trying to solve the same problems but solved them in slightly different ways.

player-03 avatar Apr 16 '23 22:04 player-03

I'd like to discourage from using std::wcstombs even on Windows because the encoding of the resulting string is locale-dependent and while some more recent versions of Windows 10 (and newer) allow to set locale to UTF-8, it's probably never the default system locale. Windows API uses UTF-16 (UCS-2 before Windows 2000) for file names and it's quite possible to have files with names that cannot be translated to a narrow string using the default system locale.

nixbody avatar Apr 17 '23 02:04 nixbody

. @joshtynjala Can you resolve the conflicts in ExternalInterface.cpp? It looks like you were both trying to solve the same problems but solved them in slightly different ways.

joshtynjala avatar Apr 17 '23 15:04 joshtynjala

In order to resolve the conflicts some maintainer needs to decide which one of those two similar functions (hl_wstring_to_utf8_bytes() vs wstring_to_vbytes()) they wish to keep. Mine is locale-independent so I think it's better but I really wish for this PR to get merged so I go either way.

nixbody avatar Apr 18 '23 08:04 nixbody

which one of those two similar functions (hl_wstring_to_utf8_bytes() vs wstring_to_vbytes()) they wish to keep

I've opened up a another PR #1665 to clean things up so hopefully we can avoid these conversions altogether.

tobil4sk avatar Apr 18 '23 12:04 tobil4sk

Actually, it looks like there are a few other places where these conversions are still required, so might need to keep one of these functions around anyway, unless those wstrings can be avoided as well.

tobil4sk avatar Apr 18 '23 12:04 tobil4sk

In order to resolve the conflicts some maintainer needs to decide which one of those two similar functions (hl_wstring_to_utf8_bytes() vs wstring_to_vbytes()) they wish to keep.

Would it be possible to decide on one of these so that these unicode issues can be fixed? Maybe @nixbody's one because it is locale independent?

(For reference, the commit that introduced the conflicts was 95411acb8c6edcecbd80e756b692dff0f55c4571)

tobil4sk avatar Dec 19 '23 11:12 tobil4sk

I've forked and resolved the merge conflicts in a separate branch, preferring hl_wstring_to_utf8_bytes over wstring_to_vbytes: https://github.com/tobil4sk/lime/tree/cffi-unicode-fixes

This is quite an important fix. If there are no objections, these changes can be pushed here and this could be merged? Then, once things are working finally, in future we can look at cleaning up the conversions in #1665.

tobil4sk avatar Dec 20 '23 18:12 tobil4sk

I didn't have permission to push your branch from my machine, so I redid the changes in the web editor. Let me know if I got anything wrong.

player-03 avatar Jan 05 '24 05:01 player-03

I added a commit here to put it in sync with my branch.

tobil4sk avatar Jan 05 '24 11:01 tobil4sk

There is a conflict now in src/lime/text/Font.hx because of #1742. I think it might be fine to keep that file as it currently is in develop, it seems to me that both changes deal with the same issue? @nixbody

tobil4sk avatar Jan 27 '24 10:01 tobil4sk

I think I'd prefer the version here, without the unsafe cast.

player-03 avatar Jan 28 '24 01:01 player-03

I think I'd prefer the version here, without the unsafe cast.

You're right, looks like this is the preferred way to handle hl.NativeArray -> Array conversions with hashlink, e.g. in hlsdl:

https://github.com/HaxeFoundation/hashlink/blob/783cd2a785b2e6f38e6b01e1b3bf5bdc19fa1173/libs/sdl/sdl/Sdl.hx#L141-L144

tobil4sk avatar Jan 28 '24 02:01 tobil4sk