summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-15 23:13:10 +0200
committerwm4 <wm4@nowhere>2013-08-15 23:40:04 +0200
commit3e6ed769357aa317bab5866da39cf0704e62fd5e (patch)
treeae79f8fa198352d8d515308c126a4cb4a94f5d59 /mpvcore
parent4246b5fbf06af067657f84d1e77bedb8faba8e87 (diff)
downloadmpv-3e6ed769357aa317bab5866da39cf0704e62fd5e.tar.bz2
mpv-3e6ed769357aa317bab5866da39cf0704e62fd5e.tar.xz
sub: don't print detected charset if it's UTF-8
Too noisy. This also fixes that iconv() was called if "utf8" was used as codepage.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/charset_conv.c12
-rw-r--r--mpvcore/charset_conv.h1
2 files changed, 9 insertions, 4 deletions
diff --git a/mpvcore/charset_conv.c b/mpvcore/charset_conv.c
index 1a2908ad08..a5c7f559ad 100644
--- a/mpvcore/charset_conv.c
+++ b/mpvcore/charset_conv.c
@@ -41,6 +41,12 @@
#include "charset_conv.h"
+bool mp_charset_is_utf8(const char *user_cp)
+{
+ return user_cp && (strcasecmp(user_cp, "utf8") == 0 ||
+ strcasecmp(user_cp, "utf-8") == 0);
+}
+
// Split the string on ':' into components.
// out_arr is at least max entries long.
// Return number of out_arr entries filled.
@@ -207,9 +213,7 @@ bstr mp_charset_guess_and_conv_to_utf8(bstr buf, const char *user_cp, int flags)
bstr mp_iconv_to_utf8(bstr buf, const char *cp, int flags)
{
#ifdef CONFIG_ICONV
- const char *tocp = "UTF-8";
-
- if (!cp || !cp[0] || strcasecmp(cp, tocp) == 0)
+ if (!cp || !cp[0] || mp_charset_is_utf8(cp))
return buf;
if (strcasecmp(cp, "ASCII") == 0)
@@ -219,7 +223,7 @@ bstr mp_iconv_to_utf8(bstr buf, const char *cp, int flags)
return bstr_sanitize_utf8_latin1(NULL, buf);
iconv_t icdsc;
- if ((icdsc = iconv_open(tocp, cp)) == (iconv_t) (-1)) {
+ if ((icdsc = iconv_open("UTF-8", cp)) == (iconv_t) (-1)) {
if (flags & MP_ICONV_VERBOSE)
mp_msg(MSGT_SUBREADER, MSGL_ERR,
"Error opening iconv with codepage '%s'\n", cp);
diff --git a/mpvcore/charset_conv.h b/mpvcore/charset_conv.h
index 171793ffab..0b2874f0ec 100644
--- a/mpvcore/charset_conv.h
+++ b/mpvcore/charset_conv.h
@@ -10,6 +10,7 @@ enum {
MP_STRICT_UTF8 = 4, // don't fall back to UTF-8-BROKEN when guessing
};
+bool mp_charset_is_utf8(const char *user_cp);
bool mp_charset_requires_guess(const char *user_cp);
const char *mp_charset_guess(bstr buf, const char *user_cp, int flags);
bstr mp_charset_guess_and_conv_to_utf8(bstr buf, const char *user_cp, int flags);