1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Fix #5456: Paths with non-ASCII characters mishandled on macOS (#5463)

This commit is contained in:
Richard Jenkins
2017-05-11 08:43:53 +01:00
committed by Michael Steenbeek
parent 3331ab8a2d
commit 86d8863496
4 changed files with 16 additions and 2 deletions

View File

@@ -133,6 +133,15 @@ utf8 *platform_open_directory_browser(const utf8 *title)
}
}
utf8* macos_str_decomp_to_precomp(utf8 *input)
{
@autoreleasepool
{
NSString *inputDecomp = [NSString stringWithUTF8String:input];
return strdup([inputDecomp.precomposedStringWithCanonicalMapping cStringUsingEncoding:NSUTF8StringEncoding]);
}
}
bool platform_open_common_file_dialog(utf8 *outFilename, file_dialog_desc *desc, size_t outSize) {
@autoreleasepool
{

View File

@@ -241,6 +241,7 @@ void core_init();
#ifdef __MACOSX__
void macos_disallow_automatic_window_tabbing();
utf8* macos_str_decomp_to_precomp();
#endif
// On macOS the resizing behaviour effectively resizes the window in the same

View File

@@ -116,7 +116,7 @@ void platform_get_time_local(rct2_time *out_time)
static size_t platform_utf8_to_multibyte(const utf8 *path, char *buffer, size_t buffer_size)
{
wchar_t *wpath = utf8_to_widechar(path);
setlocale(LC_CTYPE, "");
setlocale(LC_CTYPE, "UTF-8");
size_t len = wcstombs(NULL, wpath, 0);
bool truncated = false;
if (len > buffer_size - 1) {

View File

@@ -1966,7 +1966,11 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
w->x + window_options_misc_widgets[WIDX_WINDOW_LIMIT].left + 1,
w->y + window_options_misc_widgets[WIDX_WINDOW_LIMIT].top
);
set_format_arg(0, uintptr_t, (uintptr_t)gConfigGeneral.rct1_path);
#ifdef __MACOSX__
set_format_arg(0, uintptr_t, (uintptr_t)macos_str_decomp_to_precomp(gConfigGeneral.rct1_path));
#else
set_format_arg(0, uintptr_t, (uintptr_t)gConfigGeneral.rct1_path);
#endif
gfx_draw_string_left_clipped(
dpi,
STR_STRING,