diff options
Diffstat (limited to 'player/external_files.c')
-rw-r--r-- | player/external_files.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/player/external_files.c b/player/external_files.c index c1affcec94..fa0d6c0336 100644 --- a/player/external_files.c +++ b/player/external_files.c @@ -10,6 +10,7 @@ #include "common/global.h" #include "common/msg.h" #include "misc/ctype.h" +#include "misc/charset_conv.h" #include "options/options.h" #include "options/path.h" #include "external_files.h" @@ -98,11 +99,16 @@ static void append_dir_subtitles(struct mpv_global *global, if (mp_is_url(bstr0(fname))) goto out; - struct bstr f_fname = bstr0(mp_basename(fname)); + struct bstr f_fbname = bstr0(mp_basename(fname)); + struct bstr f_fname = mp_iconv_to_utf8(log, f_fbname, + "UTF-8-MAC", MP_NO_LATIN1_FALLBACK); struct bstr f_fname_noext = bstrdup(tmpmem, bstr_strip_ext(f_fname)); bstr_lower(f_fname_noext); struct bstr f_fname_trim = bstr_strip(f_fname_noext); + if (f_fbname.start != f_fname.start) + talloc_steal(tmpmem, f_fname.start); + // 0 = nothing // 1 = any subtitle file // 2 = any sub file containing movie name @@ -114,15 +120,19 @@ static void append_dir_subtitles(struct mpv_global *global, mp_verbose(log, "Loading external files in %.*s\n", BSTR_P(path)); struct dirent *de; while ((de = readdir(d))) { - struct bstr dename = bstr0(de->d_name); void *tmpmem2 = talloc_new(tmpmem); - + struct bstr den = bstr0(de->d_name); + struct bstr dename = mp_iconv_to_utf8(log, den, + "UTF-8-MAC", MP_NO_LATIN1_FALLBACK); // retrieve various parts of the filename struct bstr tmp_fname_noext = bstrdup(tmpmem2, bstr_strip_ext(dename)); bstr_lower(tmp_fname_noext); struct bstr tmp_fname_ext = bstr_get_ext(dename); struct bstr tmp_fname_trim = bstr_strip(tmp_fname_noext); + if (den.start != dename.start) + talloc_steal(tmpmem2, dename.start); + // check what it is (most likely) int type = test_ext(tmp_fname_ext); char **langs = NULL; |