From 9746d60cde6a55cb323de6c2d571b337151ed304 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 27 Nov 2009 19:00:42 +0000 Subject: [PATCH] [BUG_FIXED] Fix the Unicode to ANSI encoding bug. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@574 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 19 +++++++++++++++---- .../ScitillaComponent/ScintillaEditView.cpp | 10 +++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index aaa0f3c08..edf49dc1a 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -4694,16 +4694,27 @@ void Notepad_plus::command(int id) case IDM_FORMAT_CONV2_UCS_2LE: { int idEncoding = -1; - UniMode um = _pEditView->getCurrentBuffer()->getUnicodeMode(); + Buffer *buf = _pEditView->getCurrentBuffer(); + UniMode um = buf->getUnicodeMode(); + int encoding = buf->getEncoding(); switch(id) { case IDM_FORMAT_CONV2_ANSI: { - if (um == uni8Bit) - return; + if (encoding != -1) + { + // do nothing + return; + } + else + { + if (um == uni8Bit) + return; - idEncoding = IDM_FORMAT_ANSI; + // set scintilla to ANSI + idEncoding = IDM_FORMAT_ANSI; + } break; } case IDM_FORMAT_CONV2_AS_UTF_8: diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 9295d092f..c30010db3 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -1493,19 +1493,23 @@ void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask) { } if (mask & BufferChangeUnicode) { + int enc = CP_ACP; if (buffer->getUnicodeMode() == uni8Bit) { //either 0 or CJK codepage LangType typeDoc = buffer->getLangType(); if (isCJK()) { if (typeDoc == L_CSS || typeDoc == L_CAML || typeDoc == L_ASM || typeDoc == L_MATLAB) - execute(SCI_SETCODEPAGE, 0); //you may also want to set charsets here, not yet implemented + enc = CP_ACP; //you may also want to set charsets here, not yet implemented else - execute(SCI_SETCODEPAGE, _codepage); + enc = _codepage; } + else + enc = CP_ACP; } else //CP UTF8 for all unicode - execute(SCI_SETCODEPAGE, SC_CP_UTF8); + enc = SC_CP_UTF8; + execute(SCI_SETCODEPAGE, enc); } } }