From 5d71b86e818f9dfa3f7f573e438f2f6ddd5cdefc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 30 Sep 2016 09:35:17 +0100 Subject: Better tidy_for_filename that doesn't screw up with UTF-8. --- src/lib/util.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/lib/util.cc') diff --git a/src/lib/util.cc b/src/lib/util.cc index 0b300147d..00f36f217 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -53,6 +53,7 @@ extern "C" { #include #include #include +#include #include #include #ifdef DCPOMATIC_WINDOWS @@ -567,16 +568,8 @@ valid_j2k_file (boost::filesystem::path f) string tidy_for_filename (string f) { - string t; - for (size_t i = 0; i < f.length(); ++i) { - if (isalnum (f[i]) || f[i] == '_' || f[i] == '-') { - t += f[i]; - } else { - t += '_'; - } - } - - return t; + boost::replace_if (f, boost::is_any_of ("\\/:"), '_'); + return f; } dcp::Size -- cgit v1.2.3