From 8bb48853d9e60064b15e3dbc3f256a8bbe41d338 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 22 Nov 2009 11:39:03 +0000 Subject: [PATCH] [BUG_FIXED] Fix encoding files loading bug. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@568 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/ScitillaComponent/Buffer.cpp | 3 ++- PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp | 1 - PowerEditor/src/ScitillaComponent/ScintillaEditView.h | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 8288efa0b..9b9dbf501 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -699,7 +699,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language, int encoding) { const int blockSize = 128 * 1024; //128 kB - char data[blockSize]; + char data[blockSize+1]; FILE *fp = generic_fopen(filename, TEXT("rb")); if (!fp) return false; @@ -743,6 +743,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea lenFile = fread(data, 1, blockSize, fp); if (encoding != -1) { + data[lenFile] = '\0'; WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); const char *newData = wmc->encode(encoding, SC_CP_UTF8, data); _pscratchTilla->execute(SCI_APPENDTEXT, strlen(newData), (LPARAM)newData); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 764abae56..31db8aa61 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -241,7 +241,6 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) _pParameter = NppParameters::getInstance(); _codepage = ::GetACP(); - _oemCodepage = ::GetOEMCP(); //Use either Unicode or ANSI setwindowlong, depending on environment if (::IsWindowUnicode(_hSelf)) diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 4e993fb5d..56e664cb3 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -630,7 +630,6 @@ protected: folderStyle _folderStyle; NppParameters *_pParameter; int _codepage; - int _oemCodepage; bool _lineNumbersShown; bool _wrapRestoreNeeded;