[NOTEPAD] Follow-up of #5012 (0a851ea); Fix encoding

There was a bug in encoding analyzer.
CORE-14641
This commit is contained in:
Katayama Hirofumi MZ 2023-02-14 13:12:47 +09:00
parent 7014f63057
commit d3da0cb7ed

View file

@ -39,7 +39,7 @@ BOOL IsTextNonZeroASCII(const void *pText, DWORD dwSize)
ENCODING AnalyzeEncoding(const char *pBytes, DWORD dwSize)
{
INT flags = IS_TEXT_UNICODE_STATISTICS | IS_TEXT_UNICODE_REVERSE_STATISTICS;
INT flags = IS_TEXT_UNICODE_STATISTICS;
if (dwSize <= 1 || IsTextNonZeroASCII(pBytes, dwSize))
return ENCODING_ANSI;
@ -47,7 +47,9 @@ ENCODING AnalyzeEncoding(const char *pBytes, DWORD dwSize)
if (IsTextUnicode(pBytes, dwSize, &flags))
return ENCODING_UTF16LE;
if ((flags & IS_TEXT_UNICODE_REVERSE_MASK) && !(flags & IS_TEXT_UNICODE_ILLEGAL_CHARS))
flags = IS_TEXT_UNICODE_STATISTICS | IS_TEXT_UNICODE_REVERSE_STATISTICS;
IsTextUnicode(pBytes, dwSize, &flags);
if (((flags & IS_TEXT_UNICODE_REVERSE_MASK) == IS_TEXT_UNICODE_REVERSE_STATISTICS))
return ENCODING_UTF16BE;
/* is it UTF-8? */