mirror of https://github.com/mpv-player/mpv
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:
parent
f2187de8bb
commit
fc7212b214
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue