X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=340af1ea839ba8c96c75f39fcc7f671ea254255b;hb=36971ecc260b46a4092a4ba3099c3e52e2d1b916;hp=b5265519413976328254749d63cb5236caa200cd;hpb=6e5c998593842ff76f5d0ae5cab0d03cbe11b607;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index b52655194..340af1ea8 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -62,6 +62,7 @@ extern "C" { #include #include #include +#include #ifdef DCPOMATIC_WINDOWS #include #include @@ -80,6 +81,7 @@ extern "C" { #include "i18n.h" using std::string; +using std::wstring; using std::setfill; using std::ostream; using std::endl; @@ -377,7 +379,7 @@ dcpomatic_setup () Pango::init (); dcp::init (); -#ifdef DCPOMATIC_WINDOWS +#if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX) /* Render something to fontconfig to create its cache */ list subs; dcp::SubtitleString ss( @@ -743,15 +745,34 @@ careful_string_filter (string s) Safety first and all that. */ + wstring ws = boost::locale::conv::utf_to_utf(s); + string out; string const allowed = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_%.+"; - for (size_t i = 0; i < s.size(); ++i) { - if (allowed.find (s[i]) != string::npos) { - out += s[i]; + for (size_t i = 0; i < ws.size(); ++i) { + + wchar_t c = ws[i]; + + /* Remove some accents */ + if (wstring(L"áàâ").find(c) != string::npos) { + c = 'a'; + } + if (wstring(L"éèêë").find(c) != string::npos) { + c = 'e'; + } + if (wstring(L"ö").find(c) != string::npos) { + c = 'o'; + } + if (wstring(L"ü").find(c) != string::npos) { + c = 'u'; + } + + if (allowed.find(c) != string::npos) { + out += c; } } - return out; + return boost::locale::conv::utf_to_utf(out); } /** @param mapped List of mapped audio channels from a Film.