charset_conv: check for UTF-8 if uchardet returns unknown

When libuchardet returns an empty string, it can be either ASCII, UTF-8,
or an unknown encoding. Try to distinguish it from the unknown case by
checking for UTF-8. This avoids an annoying message, and avoids
unnecessary processing (we convert invalid UTF-8 sequences to latin1 to
workaround libavcodec's braindead UTF-8 check).
This commit is contained in:
wm4 2015-12-20 20:55:24 +01:00
parent f2187de8bb
commit fc7212b214
1 changed files with 2 additions and 0 deletions

View File

@ -186,6 +186,8 @@ static const char *mp_uchardet(void *talloc_ctx, struct mp_log *log, bstr buf)
iconv_close(icdsc);
}
}
if (!res && bstr_validate_utf8(buf) >= 0)
res = "utf-8";
uchardet_delete(det);
return res;
}