mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Notepad: Fixed a bug when opening files with no characters other than byte order marks
svn path=/trunk/; revision=18260
This commit is contained in:
parent
ec396aa21f
commit
ec1530d488
1 changed files with 16 additions and 5 deletions
|
@ -130,16 +130,27 @@ BOOL ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, int *piEncoding
|
|||
else
|
||||
goto done;
|
||||
|
||||
dwCharCount = MultiByteToWideChar(iCodePage, 0, (LPCSTR)&pBytes[dwPos], dwSize - dwPos, NULL, 0);
|
||||
if (dwCharCount == 0)
|
||||
goto done;
|
||||
if ((dwSize - dwPos) > 0)
|
||||
{
|
||||
dwCharCount = MultiByteToWideChar(iCodePage, 0, (LPCSTR)&pBytes[dwPos], dwSize - dwPos, NULL, 0);
|
||||
if (dwCharCount == 0)
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* special case for files with no characters (other than BOMs) */
|
||||
dwCharCount = 0;
|
||||
}
|
||||
|
||||
pszAllocText = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (dwCharCount + 1) * sizeof(WCHAR));
|
||||
if (!pszAllocText)
|
||||
goto done;
|
||||
|
||||
if (!MultiByteToWideChar(iCodePage, 0, (LPCSTR)&pBytes[dwPos], dwSize - dwPos, pszAllocText, dwCharCount))
|
||||
goto done;
|
||||
if ((dwSize - dwPos) > 0)
|
||||
{
|
||||
if (!MultiByteToWideChar(iCodePage, 0, (LPCSTR)&pBytes[dwPos], dwSize - dwPos, pszAllocText, dwCharCount))
|
||||
goto done;
|
||||
}
|
||||
|
||||
pszAllocText[dwCharCount] = '\0';
|
||||
pszText = pszAllocText;
|
||||
|
|
Loading…
Reference in a new issue