mirror of
https://github.com/reactos/reactos.git
synced 2025-07-28 10:12:14 +00:00
[0.4.13][NOTEPAD] Prioritize ASCII over UTF-8 (#2006)
To fix regression CORE-16467 which was caused by adding encoding-heuristic in 0.4.13-dev-927-ge85664a3d8
fix cherry picked from commit 0.4.14-dev-184-g142d16c8a0
This commit is contained in:
parent
09d3029dd8
commit
c35c7f2c80
1 changed files with 18 additions and 0 deletions
|
@ -48,6 +48,19 @@ static BOOL Append(LPWSTR *ppszText, DWORD *pdwTextLen, LPCWSTR pszAppendText, D
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL IsTextNonZeroASCII(const void *pText, DWORD dwSize)
|
||||||
|
{
|
||||||
|
const signed char *pBytes = pText;
|
||||||
|
while (dwSize-- > 0)
|
||||||
|
{
|
||||||
|
if (*pBytes <= 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
++pBytes;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ENCODING AnalyzeEncoding(const char *pBytes, DWORD dwSize)
|
ENCODING AnalyzeEncoding(const char *pBytes, DWORD dwSize)
|
||||||
{
|
{
|
||||||
INT flags = IS_TEXT_UNICODE_STATISTICS;
|
INT flags = IS_TEXT_UNICODE_STATISTICS;
|
||||||
|
@ -55,6 +68,11 @@ ENCODING AnalyzeEncoding(const char *pBytes, DWORD dwSize)
|
||||||
if (dwSize <= 1)
|
if (dwSize <= 1)
|
||||||
return ENCODING_ANSI;
|
return ENCODING_ANSI;
|
||||||
|
|
||||||
|
if (IsTextNonZeroASCII(pBytes, dwSize))
|
||||||
|
{
|
||||||
|
return ENCODING_ANSI;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsTextUnicode(pBytes, dwSize, &flags))
|
if (IsTextUnicode(pBytes, dwSize, &flags))
|
||||||
{
|
{
|
||||||
return ENCODING_UTF16LE;
|
return ENCODING_UTF16LE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue