mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 18:31:59 -05:00
Fix #3178: Precompose file name strings on macOS to prevent mojibake 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
This commit is contained in:
parent
0728e6869b
commit
2f9f613201
2 changed files with 16 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
0.0.8 (in development)
|
0.0.8 (in development)
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
- Fix: [#3178, #5456] Paths with non-ASCII characters not handled properly on macOS.
|
||||||
- Fix: [#3681] Steel Twister rollercoaster always shows all track designs
|
- Fix: [#3681] Steel Twister rollercoaster always shows all track designs
|
||||||
- Fix: Track components added by OpenRCT2 are now usable in older scenarios.
|
- Fix: Track components added by OpenRCT2 are now usable in older scenarios.
|
||||||
|
|
||||||
|
|
|
@ -391,6 +391,17 @@ sint32 platform_enumerate_files_begin(const utf8 *pattern)
|
||||||
safe_strcpy(paths[idx], dir_name, path_len);
|
safe_strcpy(paths[idx], dir_name, path_len);
|
||||||
safe_strcat_path(paths[idx], d->d_name, path_len);
|
safe_strcat_path(paths[idx], d->d_name, path_len);
|
||||||
log_verbose("paths[%d] = %s", idx, paths[idx]);
|
log_verbose("paths[%d] = %s", idx, paths[idx]);
|
||||||
|
|
||||||
|
// macOS uses decomposed Unicode strings (e.g. an 'e' and a combining accent) in filenames
|
||||||
|
// This causes problems with the sprite font, as the font only contains precomposed characters
|
||||||
|
// The block below converts all filename strings to their precomposed form, preventing mojibake
|
||||||
|
#ifdef __MACOSX__
|
||||||
|
utf8* precomp_path = macos_str_decomp_to_precomp(paths[idx]);
|
||||||
|
size_t precomp_len = sizeof(utf8) * min(MAX_PATH, strnlen(precomp_path, MAX_PATH) + 2);
|
||||||
|
paths[idx] = malloc(precomp_len);
|
||||||
|
safe_strcpy(paths[idx], precomp_path, precomp_len);
|
||||||
|
log_verbose("macOS decomp-to-precomp fix - paths[%d] = %s", idx, paths[idx]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
enumFileInfo->handle = 0;
|
enumFileInfo->handle = 0;
|
||||||
enumFileInfo->active = 1;
|
enumFileInfo->active = 1;
|
||||||
|
@ -798,12 +809,12 @@ time_t platform_file_get_modified_time(const utf8* path){
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 platform_get_locale_temperature_format(){
|
uint8 platform_get_locale_temperature_format(){
|
||||||
// LC_MEASUREMENT is GNU specific.
|
// LC_MEASUREMENT is GNU specific.
|
||||||
#ifdef LC_MEASUREMENT
|
#ifdef LC_MEASUREMENT
|
||||||
const char *langstring = setlocale(LC_MEASUREMENT, "");
|
const char *langstring = setlocale(LC_MEASUREMENT, "");
|
||||||
#else
|
#else
|
||||||
const char *langstring = setlocale(LC_ALL, "");
|
const char *langstring = setlocale(LC_ALL, "");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(langstring != NULL){
|
if(langstring != NULL){
|
||||||
if (!fnmatch("*_US*", langstring, 0) ||
|
if (!fnmatch("*_US*", langstring, 0) ||
|
||||||
|
|
Loading…
Reference in a new issue