static unsigned GuessEncoding_from_bytes(const String& ext, const char *src, size_t len, int guessEncodingType)
{
unsigned cp = ucr::getDefaultCodepage();
- if (guessEncodingType & 2)
+ if (!ucr::CheckForInvalidUtf8(src, len))
+ cp = CP_UTF8;
+ else if (guessEncodingType & 2)
{
IExconverter *pexconv = Exconverter::getInstance();
if (pexconv && src != NULL)
cp = pexconv->detectInputCodepage(autodetectType, cp, src, len);
}
}
- else
- {
- if (!ucr::CheckForInvalidUtf8(src, len))
- cp = CP_UTF8;
- }
if (guessEncodingType & 1)
{
if (len > BufSize)