mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
Merge pull request #106 from RaiKoHoff/Bugfixes_1006b
+bug fix: in-text encoding (convert encoding)
This commit is contained in:
commit
d225901f48
@ -31,7 +31,7 @@ setlocal
|
||||
:: ====================================================================================================================
|
||||
|
||||
:: --- Environment ---
|
||||
set VERSION=2.0.2.422
|
||||
set VERSION=2.17.1008.550
|
||||
|
||||
set SCRIPT_DIR=%~dp0
|
||||
set PORTAPP_ROOT_DIR=D:\PortableApps
|
||||
@ -39,8 +39,8 @@ set PORTAPP_LAUNCHER_CREATOR=%PORTAPP_ROOT_DIR%\PortableApps.comLauncher\Portabl
|
||||
set PORTAPP_INSTALLER_CREATOR=%PORTAPP_ROOT_DIR%\PortableApps.comInstaller\PortableApps.comInstaller.exe
|
||||
|
||||
set NP3_DISTRIB_DIR=%SCRIPT_DIR%..\distrib
|
||||
set NP3_WIN32_DIR=%SCRIPT_DIR%..\Bin\Release_x86_v141_xp
|
||||
set NP3_X64_DIR=%SCRIPT_DIR%..\Bin\Release_x64_v141_xp
|
||||
set NP3_WIN32_DIR=%SCRIPT_DIR%..\Bin\Release_x86_v141
|
||||
set NP3_X64_DIR=%SCRIPT_DIR%..\Bin\Release_x64_v141
|
||||
|
||||
set NP3_PORTAPP_DIR=%SCRIPT_DIR%Notepad3Portable
|
||||
set NP3_PORTAPP_INFO=%NP3_PORTAPP_DIR%\App\AppInfo\appinfo
|
||||
|
||||
22
src/Edit.c
22
src/Edit.c
@ -449,7 +449,8 @@ BOOL EditConvertText(HWND hwnd,int encSource,int encDest,BOOL bSetSavePoint)
|
||||
|
||||
length = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0);
|
||||
|
||||
if (length == 0) {
|
||||
if (length == 0)
|
||||
{
|
||||
SendMessage(hwnd,SCI_CANCEL,0,0);
|
||||
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
|
||||
UndoRedoSelectionMap(-1,NULL);
|
||||
@ -464,26 +465,23 @@ BOOL EditConvertText(HWND hwnd,int encSource,int encDest,BOOL bSetSavePoint)
|
||||
if (bSetSavePoint)
|
||||
SendMessage(hwnd,SCI_SETSAVEPOINT,0,0);
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
UINT cpSrc = Encoding_SciGetCodePage(hwnd); // fixed internal
|
||||
UINT cpDst = mEncoding[encDest].uCodePage;
|
||||
|
||||
if (cpSrc == cpDst)
|
||||
return(TRUE);
|
||||
|
||||
const int chLen = length * 5 + 2;
|
||||
const int chLen = length * 5 + 1;
|
||||
pchText = GlobalAlloc(GPTR,chLen);
|
||||
|
||||
tr.lpstrText = pchText;
|
||||
SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
|
||||
|
||||
const int wchLen = length * 3 + 2;
|
||||
const int wchLen = length * 3 + 1;
|
||||
pwchText = GlobalAlloc(GPTR,wchLen);
|
||||
|
||||
cbwText = MultiByteToWideChar(cpSrc,0,pchText,length,pwchText,wchLen);
|
||||
cbText = WideCharToMultiByte(cpDst,0,pwchText,cbwText,pchText,chLen,NULL,NULL);
|
||||
// MultiBytes(Sci) -> WideChar(destination) -> Sci(MultiByte)
|
||||
//UINT cpSci = mEncoding[encSource].uCodePage;
|
||||
UINT cpSci = Encoding_SciGetCodePage(hwnd); // fixed Scintilla internal
|
||||
UINT cpDst = mEncoding[encDest].uCodePage;
|
||||
cbwText = MultiByteToWideChar(cpDst,0,pchText,length,pwchText,wchLen);
|
||||
cbText = WideCharToMultiByte(cpSci,0,pwchText,cbwText,pchText,chLen,NULL,NULL);
|
||||
|
||||
SendMessage(hwnd,SCI_CANCEL,0,0);
|
||||
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
|
||||
|
||||
@ -1541,7 +1541,7 @@ void ExpandEnvironmentStringsEx(LPWSTR lpSrc,DWORD dwSrc)
|
||||
void PathCanonicalizeEx(LPWSTR lpszPath,int len)
|
||||
{
|
||||
WCHAR szDst[FILE_ARG_BUF] = { L'\0' };
|
||||
if (PathCchCanonicalize(szDst,len,lpszPath))
|
||||
if (PathCchCanonicalize(szDst,len,lpszPath) == S_OK)
|
||||
StringCchCopy(lpszPath,len,szDst);
|
||||
}
|
||||
|
||||
|
||||
@ -6508,6 +6508,7 @@ void ParseCommandLine()
|
||||
StringCchCopyN(szIniFile,COUNTOF(szIniFile),lp1,len);
|
||||
TrimString(szIniFile);
|
||||
PathUnquoteSpaces(szIniFile);
|
||||
NormalizePathEx(szIniFile,COUNTOF(szIniFile));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -6988,6 +6989,8 @@ int TestIniFile() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NormalizePathEx(szIniFile,COUNTOF(szIniFile));
|
||||
|
||||
if (!PathFileExists(szIniFile) || PathIsDirectory(szIniFile)) {
|
||||
StringCchCopy(szIniFile2,COUNTOF(szIniFile2),szIniFile);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user