mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-12-07 13:49:44 +01:00
Fix corrupted file loading for Windows full UTF-8 Code page System
Fix corrupted file loading for UTF-8 files bigger that the Notepad++ blockSize when using default system CP 65001. Notepad++ loads files in chunks of blockSize (128 * 1024 + 4 == 131076). For the 1st chunk, it detects the possible BOM present, but for the later chunks not. If there is the Windows Region Administrative feature "Beta: Use Unicode UTF-8 for worldwide language support" ON, Notepad++ currently fails to correctly set the file encoding for the later file-chunks loaded. The wrong logic was introduced by: 8149f72#diff-2d5c277be2799a7e43a90232d8ef9add2e788e252c8692bf9416abc69836957d Fix #17234, close #17237
This commit is contained in:
parent
86e3be5f6e
commit
878b00e53f
@ -1976,6 +1976,7 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * f
|
|||||||
size_t lenConvert = 0; //just in case conversion results in 0, but file not empty
|
size_t lenConvert = 0; //just in case conversion results in 0, but file not empty
|
||||||
bool isFirstTime = true;
|
bool isFirstTime = true;
|
||||||
int incompleteMultibyteChar = 0;
|
int incompleteMultibyteChar = 0;
|
||||||
|
bool hasBOM = false;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1988,9 +1989,8 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * f
|
|||||||
|
|
||||||
if (lenFile == 0) break;
|
if (lenFile == 0) break;
|
||||||
|
|
||||||
bool hasBOM = false;
|
if (isFirstTime)
|
||||||
if (isFirstTime)
|
{
|
||||||
{
|
|
||||||
NppParameters& nppParamInst = NppParameters::getInstance();
|
NppParameters& nppParamInst = NppParameters::getInstance();
|
||||||
const NppGUI& nppGui = nppParamInst.getNppGUI();
|
const NppGUI& nppGui = nppParamInst.getNppGUI();
|
||||||
|
|
||||||
@ -2023,8 +2023,8 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * f
|
|||||||
fileFormat._language = detectLanguageFromTextBeginning((unsigned char *)data, lenFile);
|
fileFormat._language = detectLanguageFromTextBeginning((unsigned char *)data, lenFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
isFirstTime = false;
|
isFirstTime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fileFormat._encoding != -1)
|
if (fileFormat._encoding != -1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user