Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accents in open/save dialogs are displayed wrongly #3178

Closed
2 tasks
rvgr opened this issue Mar 26, 2016 · 15 comments
Closed
2 tasks

Accents in open/save dialogs are displayed wrongly #3178

rvgr opened this issue Mar 26, 2016 · 15 comments
Assignees
Labels
bug Something went wrong. macOS (OS) Related to the macOS version of OpenRCT2. platform Handling that needs to be done for all supported operational systems.
Milestone

Comments

@rvgr
Copy link
Contributor

rvgr commented Mar 26, 2016

OS: MacOS 10.11.4
Version: 0.0.4

When saving or loading a game, if a file has accents in its name, it will be shown as the unaccentuated letter followed with a ?. However on the disk, accents are fine.

For example, "é" becomes "e?", "à" becomes "a?".

  • Reproducable in RCT2 (vanilla)?
  • Multiplayer?

Screenshots / Video:
capture d ecran 2016-03-26 a 14 50 47
« Frontie?res Forestie?res » should read as « Frontières Forestières ».

capture d ecran 2016-03-26 a 14 54 00
It's fine in the Finder.

@rvgr rvgr changed the title Special characters in open/save dialogs are wrong Accents in open/save dialogs are displayed wrongly Mar 26, 2016
@IntelOrca
Copy link
Contributor

I can't reproduce this on Windows, so possible OSX / Posix only?

@IntelOrca IntelOrca added the investigate Not sure what the problem is yet. label Mar 26, 2016
@HaasJona
Copy link
Contributor

AFAIK osx saves the accents in the file system as Unicode combining characters. So it's first an e character and then a combining ` character for example.

We probably need to canonicalize the filenames first before displaying them. Or alternatively support Unicode properly, probably not possible with the bitmap fonts.

@IntelOrca
Copy link
Contributor

@HaasJona no, it works fine in Windows with accents - the problem is the conversion from the OS encoding to UTF-8, in platform_enumerate_files_begin. I don't know whether this differs or not between Linux and OSX.

@HaasJona
Copy link
Contributor

I know it works fine in Windows with accents. But that is because windows doesn't use combining characters. In Windows the é is a single character, on osx, it is 2 characters.

@IntelOrca
Copy link
Contributor

@HaasJona The problem lies in posix.c:platform_enumerate_files_begin... the code is not correctly converting the string from whatever the OS stores it as to UTF-8. Windows is fine because I correctly convert it from widechar to UTF-8.

@HaasJona
Copy link
Contributor

Well, it works fine in Linux, and the fact that the e is displayed correctly makes me 90% sure that I'm correct. You could test it by switching to a locale with ttf fonts, then the ` character should be there if I'm right.

screenshot

@IntelOrca
Copy link
Contributor

If it works in Linux, then OSX needs some extra code to convert to UTF-8 just like Windows has. This has to happen in the platform_enumerate_files_begin function.

@HaasJona
Copy link
Contributor

You are certainly correct, but what I'm saying is that I believe that OSX already returns the file name in UTF-8, just that its "weird" UTF-8, because for example ç isn't encoded as 0xC48D (which would be the usual UTF-8 encoding as expected by the game), but as 0x63CC8C which would be a normal c (0x63) and a combining caron (0xCC8C). But both are technically correct UTF-8 representation, It's probably just an issue with the game that there is no sprite for the combining character (and a generally missing functionality of overlaying multiple sprites for a single character), so we either need to handle all UTF-8 correctly or we need to "recombine" (normalize) the file names the OS give us, by "translating" 0x63CC8C back to 0xC48D. There are probably library functions for that, but I only know the API for Java and not C/C++.

@IntelOrca
Copy link
Contributor

The only function that should be changed is platform_enumerate_files_begin so that the filename is correctly converted into the encoding the game expects. The bitmap sprite will then be drawn correctly, as for TTF - that will depend on how SDL_TTF works on OSX.

@HaasJona
Copy link
Contributor

The bitmap sprite will then be drawn correctly

I really doubt that the current code bitmap is able to draw combining characters correctly.

@IntelOrca
Copy link
Contributor

@HaasJona It will draw correctly because the filename will have been converted to the correct UTF-8 encoding the game understands where an é will be one single codepoint that maps to a sprite.

@IntelOrca IntelOrca added bug Something went wrong. platform Handling that needs to be done for all supported operational systems. macOS (OS) Related to the macOS version of OpenRCT2. and removed investigate Not sure what the problem is yet. labels Mar 27, 2016
@HaasJona
Copy link
Contributor

@IntelOrca OK. What I mean is that the representation as 2 codepoints is technically just as correct as the normal 1 codepoint representation. You may have seen text like ̷ͮt߳̀̽͘ͅh̸͓͓͉̦́͌̑᷄҆߱í̱̝̻̉͒͡s͚̓̀ which is just normal UTF-8 with random combining characters, too. So there is nothing wrong or incorrect about that.

Normalizing the file names OSX gives us in platform_enumerate_files_begin will solve the problem and is probably an okay solution. Strings like ̷ͮt߳̀̽͘ͅh̸͓͓͉̦́͌̑᷄҆߱í̱̝̻̉͒͡s͚̓̀ will obviously still render incorrectly in game because they aren't normalizable, but that's probably fine for now.

@Gymnasiast
Copy link
Member

This needs the same treatment as loading the RCT2 files for a folder with accents, whcih @rwjuk fixed.

@Gymnasiast
Copy link
Member

Gymnasiast commented May 22, 2017

@rwjuk I haven't yet been able to check whether this bug has been solved by your earlier work or not. If it's already fixed then this obviously can be closed.
When this is closed, don't forget the changelog entry.

@rwjuk
Copy link
Contributor

rwjuk commented May 22, 2017

I will have a look - if not, it'll almost certainly just be adding in appropriate calls to the precomposition function for macOS.

@Gymnasiast Gymnasiast added this to the v0.0.8 - seventh release milestone May 22, 2017
Gymnasiast pushed a commit that referenced this issue May 23, 2017
…when displayed

* Precompose file name strings on macOS to prevent mojibake when displayed

* Ensure decomp-to-precomp string replacement is handled safely

* Add macOS non-ASCII handling to changelog; add comments to relevant block

* Fix #ifdef alignment

* Fix comment alignment
janisozaur added a commit that referenced this issue Jul 12, 2017
- Feature: [#1399 (partial), #5177] Add window that displays any missing/corrupt objects when loading a park
- Feature: [#5056] Add cheat to own all land.
- Feature: [#5133] Add option to display guest expenditure (as seen in RCTC).
- Feature: [#5196] Add cheat to disable ride ageing.
- Feature: [#5504] Group vehicles into ride groups
- Feature: [#5576] Add a persistent 'display real names of guests' setting.
- Feature: [#5611] Add support for Android
- Feature: [#5706] Add support for OpenBSD
- Feature: OpenRCT2 now starts up on the display it was last shown on.
- Feature: Park entrance fee can now be set to amounts up to £200.
- Improved: Construction rights can now be placed on park entrances.
- Improved: Mouse can now be dragged to select scenery when saving track designs
- Fix: [#259] Money making glitch involving swamps (original bug)
- Fix: [#441] Construction rights over entrance path erased (original bug)
- Fix: [#578] Ride ghosts show up in ride list during construction (original bug)
- Fix: [#597] 'Finish 5 roller coasters' goal not properly checked (original bug)
- Fix: [#667] Incorrect banner limit calculation (original bug)
- Fix: [#739] Crocodile Ride (Log Flume) never allows more than five boats (original bug)
- Fix: [#837] Can't move windows on title screen to where the toolbar would be (original bug)
- Fix: [#1705] Time Twister's Medieval entrance has incorrect scrolling (original bug)
- Fix: [#3178, #5456] Paths with non-ASCII characters not handled properly on macOS.
- Fix: [#3346] Crash when extra long train breaks down at the back
- Fix: [#3479] Building in pause mode creates too many floating numbers, crashing the game
- Fix: [#3565] Multiplayer server crash
- Fix: [#3681] Steel Twister rollercoaster always shows all track designs
- Fix: [#3846, #5749] Crash when testing coaster with a diagonal lift in block brake mode
- Fix: [#4054] Sorting rides by track type: Misleading research messages
- Fix: [#4055] Sort rides by track type: Sorting rule is not really clear (inconsistent?)
- Fix: [#4512] Invisible map edge tiles corrupted
- Fix: [#5009] Ride rating calculations can overflow
- Fix: [#5253] RCT1 park value conversion factor too high
- Fix: [#5400] New Ride window does not focus properly on newly invented ride.
- Fix: [#5489] Sprite index crash for car view on car ride.
- Fix: [#5730] Unable to uncheck 'No money' in the Scenario Editor.
- Fix: [#5750] Game freezes when ride queue linked list is corrupted.
- Fix: [#5819] Vertical multi-dimension coaster tunnels drawn incorrectly
- Fix: Non-invented vehicles can be used via track designs in select-by-track-type mode.
- Fix: Track components added by OpenRCT2 are now usable in older scenarios.
- Technical: [#5047] Add ride ratings tests
- Technical: [#5458] Begin offering headless build with reduced compile- and run-time dependencies
- Technical: [#5755] Title sequence wait periods use milliseconds
- Technical: Fix many desync sources
ZehMatt pushed a commit to ZehMatt/OpenRCT2 that referenced this issue Jul 14, 2017
…ojibake when displayed

* Precompose file name strings on macOS to prevent mojibake when displayed

* Ensure decomp-to-precomp string replacement is handled safely

* Add macOS non-ASCII handling to changelog; add comments to relevant block

* Fix #ifdef alignment

* Fix comment alignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something went wrong. macOS (OS) Related to the macOS version of OpenRCT2. platform Handling that needs to be done for all supported operational systems.
Projects
None yet
Development

No branches or pull requests

5 participants