https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d3da0cb7edf37448b74d7…
commit d3da0cb7edf37448b74d7ef4cf3af18689ec3ff4
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Feb 14 13:12:47 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Tue Feb 14 13:12:47 2023 +0900
[NOTEPAD] Follow-up of #5012 (0a851ea); Fix encoding
There was a bug in encoding analyzer.
CORE-14641
---
base/applications/notepad/text.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/base/applications/notepad/text.c b/base/applications/notepad/text.c
index 0025ddf9dac..86b0fa78c37 100644
--- a/base/applications/notepad/text.c
+++ b/base/applications/notepad/text.c
@@ -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? */