diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index ae5ab03c..f34af933 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -843,20 +843,6 @@ void Notepad_plus::fileNew() BufferID newBufID = MainFileManager->newEmptyDocument(); loadBufferIntoView(newBufID, currentView(), true); //true, because we want multiple new files if possible activateBuffer(newBufID, currentView()); - - NppParameters *pNppParam = NppParameters::getInstance(); - NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); - NewDocDefaultSettings & ndds = (NewDocDefaultSettings &)nppGUI.getNewDocDefaultSettings(); - if (ndds._codepage != -1) - { - EncodingMapper *em = EncodingMapper::getInstance(); - int cmdID = em->getIndexFromEncoding(ndds._codepage); - if (cmdID != -1) - { - cmdID += IDM_FORMAT_ENCODE; - ::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, cmdID, 0); - } - } } bool Notepad_plus::isFileSession(const TCHAR * filename) { diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 7ac6eb70..2745ee57 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "Parameters.h" #include "Notepad_plus.h" #include "ScintillaEditView.h" +#include "EncodingMapper.h" FileManager * FileManager::_pSelf = new FileManager(); @@ -42,6 +43,9 @@ Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); _format = ndds._format; _unicodeMode = ndds._encoding; + _encoding = ndds._codepage; + if (_encoding != -1) + _unicodeMode = uniCookie; _userLangExt[0] = 0; _fullPathName[0] = 0; @@ -463,6 +467,12 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin _nrBufs++; Buffer * buf = _buffers.at(_nrBufs - 1); + // restore the encoding (ANSI based) while opening the existing file + NppParameters *pNppParamInst = NppParameters::getInstance(); + const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); + buf->setUnicodeMode(ndds._encoding); + buf->setEncoding(-1); + if (encoding == -1) { // 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT @@ -480,8 +490,6 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin UniMode um = UnicodeConvertor.getEncoding(); if (um == uni7Bit) { - NppParameters *pNppParamInst = NppParameters::getInstance(); - const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); if (ndds._openAnsiAsUtf8) { um = uniCookie;