From dcf1270fc4ca66aebb0fab9034b175f5338bc6d2 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 15 Apr 2014 16:51:27 -0700 Subject: [PATCH] Ensure boost.locale is initialized with a UTF-8 locale on OS X This fixes the find/replace dialog stripping non-us-ascii characters from the file. See #1587 for the same issue on Windows. --- src/main.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ac7011252..74e98557c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -121,18 +121,17 @@ bool AegisubApp::OnInit() { // be created now (void)wxLog::GetActiveTarget(); +#ifdef __APPLE__ + // When launched from Finder, boost::locale fails to get the correct locale + // and falls back to "C", which of course doesn't support unicode + std::locale::global(boost::locale::generator().generate("en_US.UTF-8")); +#else // Set the global locale to the utf-8 version of the current locale std::locale::global(boost::locale::generator().generate("")); - -#ifndef __APPLE__ - // Boost.FileSystem always uses UTF-8 for paths on OS X (since paths - // actually are required to be UTF-8 strings rather than just opaque binary - // blobs like on Linux), so there's no need to imbue the new locale and in - // fact it actively breaks things for unknown reasons when launching the - // app from Finder (but not from the command line). - boost::filesystem::path::imbue(std::locale()); #endif + boost::filesystem::path::imbue(std::locale()); + // Pointless `this` capture required due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51494 agi::dispatch::Init([this](agi::dispatch::Thunk f) { auto evt = new wxThreadEvent(EVT_CALL_THUNK);