summaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-16 23:54:25 +0100
committerwm4 <wm4@nowhere>2015-12-17 01:17:23 +0100
commit74c11f0c841d0b81a6ea759c7eb131d2c2e02ec3 (patch)
tree8c88229f881d63d3bb1504db7ca72583ae5eafcf /misc
parente798cf1ff64527cd2ed9fc3bab8dbc2d0c7a52de (diff)
downloadmpv-74c11f0c841d0b81a6ea759c7eb131d2c2e02ec3.tar.bz2
mpv-74c11f0c841d0b81a6ea759c7eb131d2c2e02ec3.tar.xz
sub: detect charset in demuxer
Slightly simpler, and removes the need to pre-read all subtitle packets. This still does the subtitle charset conversion on the packet level (instead converting when parsing the file), so in theory this still could provide a way to change the charset at runtime. But maybe even this should be removed, as FFmpeg is somewhat likely to get its own charset detection and conversion mechanism in the future. (Would have to keep the subtitle file in memory to allow changing the charset on the fly, I guess.)
Diffstat (limited to 'misc')
-rw-r--r--misc/charset_conv.c7
-rw-r--r--misc/charset_conv.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/misc/charset_conv.c b/misc/charset_conv.c
index 3e7e47cc58..8181b1392e 100644
--- a/misc/charset_conv.c
+++ b/misc/charset_conv.c
@@ -52,6 +52,13 @@ bool mp_charset_is_utf8(const char *user_cp)
strcasecmp(user_cp, "utf-8") == 0);
}
+bool mp_charset_is_utf16(const char *user_cp)
+{
+ bstr s = bstr0(user_cp);
+ return bstr_case_startswith(s, bstr0("utf16")) ||
+ bstr_case_startswith(s, bstr0("utf-16"));
+}
+
// Split the string on ':' into components.
// out_arr is at least max entries long.
// Return number of out_arr entries filled.
diff --git a/misc/charset_conv.h b/misc/charset_conv.h
index 3d3520fb2b..ddfabbe49e 100644
--- a/misc/charset_conv.h
+++ b/misc/charset_conv.h
@@ -13,6 +13,7 @@ enum {
};
bool mp_charset_is_utf8(const char *user_cp);
+bool mp_charset_is_utf16(const char *user_cp);
bool mp_charset_requires_guess(const char *user_cp);
const char *mp_charset_guess(void *talloc_ctx, struct mp_log *log, bstr buf,
const char *user_cp, int flags);