mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
+ refactoring: prepare for enhanced encoding detection
This commit is contained in:
parent
85dd425893
commit
4576f08454
@ -44,6 +44,8 @@
|
||||
#include "resource.h"
|
||||
#include "version.h"
|
||||
#include "helpers.h"
|
||||
#include "encoding.h"
|
||||
|
||||
#include "dialogs.h"
|
||||
|
||||
|
||||
|
||||
83
src/Edit.c
83
src/Edit.c
@ -32,6 +32,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "scintilla.h"
|
||||
#include "scilexer.h"
|
||||
#include "notepad3.h"
|
||||
@ -42,9 +43,13 @@
|
||||
#include "../uthash/utarray.h"
|
||||
//#include "../uthash/utstring.h"
|
||||
#include "helpers.h"
|
||||
#include "edit.h"
|
||||
#include "encoding.h"
|
||||
|
||||
#include "SciCall.h"
|
||||
|
||||
#include "edit.h"
|
||||
|
||||
|
||||
#ifndef LCMAP_TITLECASE
|
||||
#define LCMAP_TITLECASE 0x00000300 // Title Case Letters bit mask
|
||||
#endif
|
||||
@ -103,9 +108,6 @@ extern int g_iTabWidth;
|
||||
extern int g_iIndentWidth;
|
||||
|
||||
|
||||
extern NP2ENCODING g_Encodings[];
|
||||
|
||||
|
||||
#define DELIM_BUFFER 258
|
||||
static char DelimChars[DELIM_BUFFER] = { '\0' };
|
||||
static char DelimCharsAccel[DELIM_BUFFER] = { '\0' };
|
||||
@ -411,9 +413,9 @@ BOOL EditConvertText(HWND hwnd, int encSource, int encDest, BOOL bSetSavePoint)
|
||||
WCHAR* pwchText = GlobalAlloc(GPTR,wchBufSize);
|
||||
|
||||
// MultiBytes(Sci) -> WideChar(destination) -> Sci(MultiByte)
|
||||
//UINT cpSci = g_Encodings[encSource].uCodePage;
|
||||
//UINT cpSci = Encoding_GetCodePage(encSource);
|
||||
UINT cpSci = Encoding_SciGetCodePage(hwnd); // fixed Scintilla internal (UTF-8)
|
||||
UINT cpDst = g_Encodings[encDest].uCodePage;
|
||||
UINT cpDst = Encoding_GetCodePage(encDest);
|
||||
|
||||
// get text as wide char
|
||||
int cbwText = MultiByteToWideChar(cpSci,0, pchText, (int)length, pwchText, (int)wchBufSize);
|
||||
@ -495,13 +497,13 @@ BOOL EditIsRecodingNeeded(WCHAR* pszText, int cchLen)
|
||||
if ((pszText == NULL) || (cchLen < 1))
|
||||
return FALSE;
|
||||
|
||||
UINT codepage = g_Encodings[Encoding_Current(CPI_GET)].uCodePage;
|
||||
UINT codepage = Encoding_GetCodePage(Encoding_Current(CPI_GET));
|
||||
|
||||
if ((codepage == CP_UTF7) || (codepage == CP_UTF8))
|
||||
return FALSE;
|
||||
|
||||
DWORD dwFlags = WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR;
|
||||
BOOL useNullParams = (g_Encodings[Encoding_Current(CPI_GET)].uFlags & NCP_MBCS) ? TRUE : FALSE;
|
||||
BOOL useNullParams = Encoding_IsMBCS(Encoding_Current(CPI_GET)) ? TRUE : FALSE;
|
||||
|
||||
BOOL bDefaultCharsUsed = FALSE;
|
||||
int cch = 0;
|
||||
@ -1061,10 +1063,10 @@ BOOL EditLoadFile(
|
||||
bPreferOEM = TRUE;
|
||||
}
|
||||
|
||||
const int iFileEncoding = Encoding_SrcCmdLn(CPI_GET);
|
||||
const int iForcedEncoding = Encoding_SrcCmdLn(CPI_GET);
|
||||
const int iFileEncWeak = (Encoding_SrcWeak(CPI_GET) != CPI_NONE) ? Encoding_SrcWeak(CPI_GET) : CPI_ANSI_DEFAULT;
|
||||
const int iPreferedEncoding = (bPreferOEM) ? g_DOSEncoding : (bUseDefaultForFileEncoding ? g_iDefaultNewFileEncoding : iFileEncWeak);
|
||||
//@@@(g_Encodings[iFileEncWeak].uFlags & NCP_INTERNAL) ? g_iDefaultNewFileEncoding : iFileEncWeak;
|
||||
//@@@ Encoding_IsINTERNAL(iFileEncWeak) ? g_iDefaultNewFileEncoding : iFileEncWeak;
|
||||
|
||||
BOOL bBOM = FALSE;
|
||||
BOOL bReverse = FALSE;
|
||||
@ -1072,36 +1074,35 @@ BOOL EditLoadFile(
|
||||
if (cbData == 0) {
|
||||
FileVars_Init(NULL,0,&fvCurFile);
|
||||
*iEOLMode = iLineEndings[g_iDefaultEOLMode];
|
||||
if (iFileEncoding == CPI_NONE) {
|
||||
if (iForcedEncoding == CPI_NONE) {
|
||||
if (bLoadASCIIasUTF8 && !bPreferOEM)
|
||||
*iEncoding = CPI_UTF8;
|
||||
else
|
||||
*iEncoding = iPreferedEncoding;
|
||||
}
|
||||
else
|
||||
*iEncoding = iFileEncoding;
|
||||
*iEncoding = iForcedEncoding;
|
||||
|
||||
Encoding_SciSetCodePage(hwnd,*iEncoding);
|
||||
EditSetNewText(hwnd,"",0);
|
||||
SendMessage(hwnd,SCI_SETEOLMODE,iLineEndings[g_iDefaultEOLMode],0);
|
||||
GlobalFree(lpData);
|
||||
}
|
||||
|
||||
else if (!bSkipEncodingDetection &&
|
||||
(iFileEncoding == CPI_NONE || iFileEncoding == CPI_UNICODE || iFileEncoding == CPI_UNICODEBE) &&
|
||||
(iFileEncoding == CPI_UNICODE || iFileEncoding == CPI_UNICODEBE || IsUnicode(lpData,cbData,&bBOM,&bReverse)) &&
|
||||
(iFileEncoding == CPI_UNICODE || iFileEncoding == CPI_UNICODEBE || !IsUTF8Signature(lpData))) // check for UTF-8 signature
|
||||
(iForcedEncoding == CPI_NONE || iForcedEncoding == CPI_UNICODE || iForcedEncoding == CPI_UNICODEBE) &&
|
||||
(iForcedEncoding == CPI_UNICODE || iForcedEncoding == CPI_UNICODEBE || IsUnicode(lpData,cbData,&bBOM,&bReverse)) &&
|
||||
(iForcedEncoding == CPI_UNICODE || iForcedEncoding == CPI_UNICODEBE || !IsUTF8Signature(lpData))) // check for UTF-8 signature
|
||||
{
|
||||
char* lpDataUTF8;
|
||||
|
||||
if (iFileEncoding == CPI_UNICODE) {
|
||||
if (iForcedEncoding == CPI_UNICODE) {
|
||||
bBOM = (*((UNALIGNED PWCHAR)lpData) == 0xFEFF);
|
||||
bReverse = FALSE;
|
||||
}
|
||||
else if (iFileEncoding == CPI_UNICODEBE)
|
||||
else if (iForcedEncoding == CPI_UNICODEBE)
|
||||
bBOM = (*((UNALIGNED PWCHAR)lpData) == 0xFFFE);
|
||||
|
||||
if (iFileEncoding == CPI_UNICODEBE || bReverse) {
|
||||
if (iForcedEncoding == CPI_UNICODEBE || bReverse) {
|
||||
_swab(lpData,lpData,cbData);
|
||||
if (bBOM)
|
||||
*iEncoding = CPI_UNICODEBEBOM;
|
||||
@ -1148,18 +1149,17 @@ BOOL EditLoadFile(
|
||||
|
||||
else {
|
||||
FileVars_Init(lpData,cbData,&fvCurFile);
|
||||
if (!bSkipEncodingDetection && (iFileEncoding == CPI_NONE || iFileEncoding == CPI_UTF8 || iFileEncoding == CPI_UTF8SIGN) &&
|
||||
if (!bSkipEncodingDetection && (iForcedEncoding == CPI_NONE || iForcedEncoding == CPI_UTF8 || iForcedEncoding == CPI_UTF8SIGN) &&
|
||||
((IsUTF8Signature(lpData) ||
|
||||
FileVars_IsUTF8(&fvCurFile) ||
|
||||
(iFileEncoding == CPI_UTF8 || iFileEncoding == CPI_UTF8SIGN) ||
|
||||
(iForcedEncoding == CPI_UTF8 || iForcedEncoding == CPI_UTF8SIGN) ||
|
||||
(!bPreferOEM && bLoadASCIIasUTF8) || // from menu "Reload As UTF-8"
|
||||
(IsUTF8(lpData,cbData) &&
|
||||
(((UTF8_mbslen_bytes(UTF8StringStart(lpData)) - 1 !=
|
||||
UTF8_mbslen(UTF8StringStart(lpData),IsUTF8Signature(lpData) ? cbData-3 : cbData)) ||
|
||||
(!bPreferOEM && (
|
||||
g_Encodings[iPreferedEncoding].uFlags & NCP_UTF8 ||
|
||||
bLoadASCIIasUTF8))))))) && !(FileVars_IsNonUTF8(&fvCurFile) &&
|
||||
(iFileEncoding != CPI_UTF8 && iFileEncoding != CPI_UTF8SIGN)))
|
||||
Encoding_IsUTF8(iPreferedEncoding) || bLoadASCIIasUTF8))))))) && !(FileVars_IsNonUTF8(&fvCurFile) &&
|
||||
(iForcedEncoding != CPI_UTF8 && iForcedEncoding != CPI_UTF8SIGN)))
|
||||
{
|
||||
Encoding_SciSetCodePage(hwnd,CPI_UTF8);
|
||||
EditSetNewText(hwnd,"",0);
|
||||
@ -1178,8 +1178,8 @@ BOOL EditLoadFile(
|
||||
|
||||
else {
|
||||
|
||||
if (iFileEncoding != CPI_NONE)
|
||||
*iEncoding = iFileEncoding;
|
||||
if (iForcedEncoding != CPI_NONE)
|
||||
*iEncoding = iForcedEncoding;
|
||||
else {
|
||||
*iEncoding = FileVars_GetEncoding(&fvCurFile);
|
||||
if (*iEncoding == CPI_NONE) {
|
||||
@ -1191,10 +1191,10 @@ BOOL EditLoadFile(
|
||||
}
|
||||
}
|
||||
|
||||
if (((g_Encodings[*iEncoding].uCodePage != CP_UTF7) && (g_Encodings[*iEncoding].uFlags & NCP_EXTERNAL_8BIT)) ||
|
||||
((g_Encodings[*iEncoding].uCodePage == CP_UTF7) && IsUTF7(lpData,cbData))) {
|
||||
if (((Encoding_GetCodePage(*iEncoding) != CP_UTF7) && Encoding_IsEXTERNAL_8BIT(*iEncoding)) ||
|
||||
((Encoding_GetCodePage(*iEncoding) == CP_UTF7) && IsUTF7(lpData,cbData))) {
|
||||
|
||||
UINT uCodePage = g_Encodings[*iEncoding].uCodePage;
|
||||
UINT uCodePage = Encoding_GetCodePage(*iEncoding);
|
||||
|
||||
LPWSTR lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16);
|
||||
int cbDataWide = MultiByteToWideChar(uCodePage,0,lpData,cbData,lpDataWide,(int)GlobalSize(lpDataWide)/sizeof(WCHAR));
|
||||
@ -1229,7 +1229,7 @@ BOOL EditLoadFile(
|
||||
}
|
||||
}
|
||||
else {
|
||||
*iEncoding = Encoding_IsValid(iFileEncoding) ? iFileEncoding : iPreferedEncoding;
|
||||
*iEncoding = Encoding_IsValid(iForcedEncoding) ? iForcedEncoding : iPreferedEncoding;
|
||||
Encoding_SciSetCodePage(hwnd,*iEncoding);
|
||||
EditSetNewText(hwnd,"",0);
|
||||
EditSetNewText(hwnd,lpData,cbData);
|
||||
@ -1343,19 +1343,19 @@ BOOL EditSaveFile(
|
||||
}
|
||||
}*/
|
||||
|
||||
if (g_Encodings[iEncoding].uFlags & NCP_UNICODE)
|
||||
if (Encoding_IsUNICODE(iEncoding))
|
||||
{
|
||||
SetEndOfFile(hFile);
|
||||
|
||||
LPWSTR lpDataWide = GlobalAlloc(GPTR, cbData * 2 + 16);
|
||||
int bomoffset = 0;
|
||||
if (g_Encodings[iEncoding].uFlags & NCP_UNICODE_BOM) {
|
||||
if (Encoding_IsUNICODE_BOM(iEncoding)) {
|
||||
const char* bom = "\xFF\xFE";
|
||||
CopyMemory((char*)lpDataWide, bom, 2);
|
||||
bomoffset = 1;
|
||||
}
|
||||
int cbDataWide = bomoffset + MultiByteToWideChar(Encoding_SciGetCodePage(hwnd), 0, lpData, cbData, &lpDataWide[bomoffset], (int)GlobalSize(lpDataWide) / sizeof(WCHAR) - bomoffset);
|
||||
if (g_Encodings[iEncoding].uFlags & NCP_UNICODE_REVERSE) {
|
||||
if (Encoding_IsUNICODE_REVERSE(iEncoding)) {
|
||||
_swab((char*)lpDataWide, (char*)lpDataWide, cbDataWide * sizeof(WCHAR));
|
||||
}
|
||||
bWriteSuccess = EncryptAndWriteFile(hwnd, hFile, (BYTE*)lpDataWide, cbDataWide * sizeof(WCHAR), &dwBytesWritten);
|
||||
@ -1365,11 +1365,11 @@ BOOL EditSaveFile(
|
||||
GlobalFree(lpData);
|
||||
}
|
||||
|
||||
else if (g_Encodings[iEncoding].uFlags & NCP_UTF8)
|
||||
else if (Encoding_IsUTF8(iEncoding))
|
||||
{
|
||||
SetEndOfFile(hFile);
|
||||
|
||||
if (g_Encodings[iEncoding].uFlags & NCP_UTF8_SIGN) {
|
||||
if (Encoding_IsUTF8_SIGN(iEncoding)) {
|
||||
const char* bom = "\xEF\xBB\xBF";
|
||||
DWORD bomoffset = 3;
|
||||
MoveMemory(&lpData[bomoffset], lpData, cbData);
|
||||
@ -1383,15 +1383,15 @@ BOOL EditSaveFile(
|
||||
GlobalFree(lpData);
|
||||
}
|
||||
|
||||
else if (g_Encodings[iEncoding].uFlags & NCP_EXTERNAL_8BIT) {
|
||||
else if (Encoding_IsEXTERNAL_8BIT(iEncoding)) {
|
||||
|
||||
BOOL bCancelDataLoss = FALSE;
|
||||
UINT uCodePage = g_Encodings[iEncoding].uCodePage;
|
||||
UINT uCodePage = Encoding_GetCodePage(iEncoding);
|
||||
|
||||
LPWSTR lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16);
|
||||
int cbDataWide = MultiByteToWideChar(Encoding_SciGetCodePage(hwnd),0,lpData,cbData,lpDataWide,(int)GlobalSize(lpDataWide)/sizeof(WCHAR));
|
||||
|
||||
if (g_Encodings[iEncoding].uFlags & NCP_MBCS) {
|
||||
if (Encoding_IsMBCS(iEncoding)) {
|
||||
GlobalFree(lpData);
|
||||
lpData = GlobalAlloc(GPTR, GlobalSize(lpDataWide) * 2); // need more space
|
||||
cbData = WideCharToMultiByte(uCodePage, 0, lpDataWide, cbDataWide, lpData, (int)GlobalSize(lpData), NULL, NULL);
|
||||
@ -7361,16 +7361,15 @@ BOOL FileVars_IsValidEncoding(LPFILEVARS lpfv) {
|
||||
if (lpfv->mask & FV_ENCODING &&
|
||||
lpfv->iEncoding >= 0 &&
|
||||
lpfv->iEncoding < Encoding_CountOf()) {
|
||||
if ((g_Encodings[lpfv->iEncoding].uFlags & NCP_INTERNAL) ||
|
||||
IsValidCodePage(g_Encodings[lpfv->iEncoding].uCodePage) &&
|
||||
GetCPInfo(g_Encodings[lpfv->iEncoding].uCodePage,&cpi)) {
|
||||
if ((Encoding_IsINTERNAL(lpfv->iEncoding)) ||
|
||||
IsValidCodePage(Encoding_GetCodePage(lpfv->iEncoding)) &&
|
||||
GetCPInfo(Encoding_GetCodePage(lpfv->iEncoding),&cpi)) {
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// FileVars_GetEncoding()
|
||||
|
||||
1577
src/Encoding.c
Normal file
1577
src/Encoding.c
Normal file
File diff suppressed because it is too large
Load Diff
139
src/Encoding.h
Normal file
139
src/Encoding.h
Normal file
@ -0,0 +1,139 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* *
|
||||
* Notepad3 *
|
||||
* *
|
||||
* Encoding.h *
|
||||
* *
|
||||
* Copyright (C) 2006-2016 Wu Yongwei <wuyongwei@gmail.com> *
|
||||
* *
|
||||
* This software is provided 'as-is', without any express or implied *
|
||||
* warranty. In no event will the authors be held liable for any *
|
||||
* damages arising from the use of this software. *
|
||||
* *
|
||||
* Permission is granted to anyone to use this software for any purpose, *
|
||||
* including commercial applications, and to alter it and redistribute *
|
||||
* it freely, subject to the following restrictions: *
|
||||
* *
|
||||
* 1. The origin of this software must not be misrepresented; you must *
|
||||
* not claim that you wrote the original software. If you use this *
|
||||
* software in a product, an acknowledgement in the product *
|
||||
* documentation would be appreciated but is not required. *
|
||||
* 2. Altered source versions must be plainly marked as such, and must *
|
||||
* not be misrepresented as being the original software. *
|
||||
* 3. This notice may not be removed or altered from any source *
|
||||
* distribution. *
|
||||
* *
|
||||
* *
|
||||
* The latest version of this software should be available at: *
|
||||
* <URL:https://github.com/adah1972/tellenc> *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
#ifndef _NP3_ENCODING_H_
|
||||
#define _NP3_ENCODING_H_
|
||||
|
||||
|
||||
//__forceinline void swapi(int* a, int* b) { int t = *a; *a = *b; *b = t; }
|
||||
|
||||
|
||||
extern int g_DOSEncoding;
|
||||
|
||||
#define NCP_DEFAULT 1
|
||||
#define NCP_UTF8 2
|
||||
#define NCP_UTF8_SIGN 4
|
||||
#define NCP_UNICODE 8
|
||||
#define NCP_UNICODE_REVERSE 16
|
||||
#define NCP_UNICODE_BOM 32
|
||||
#define NCP_ANSI 64
|
||||
#define NCP_OEM 128
|
||||
#define NCP_MBCS 256
|
||||
#define NCP_INTERNAL (NCP_DEFAULT|NCP_UTF8|NCP_UTF8_SIGN|NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM|NCP_ANSI|NCP_OEM|NCP_MBCS)
|
||||
#define NCP_EXTERNAL_8BIT 512
|
||||
#define NCP_RECODE 1024
|
||||
|
||||
#define CPI_GET -2
|
||||
#define CPI_NONE -1
|
||||
#define CPI_ANSI_DEFAULT 0
|
||||
#define CPI_OEM 1
|
||||
#define CPI_UNICODEBOM 2
|
||||
#define CPI_UNICODEBEBOM 3
|
||||
#define CPI_UNICODE 4
|
||||
#define CPI_UNICODEBE 5
|
||||
#define CPI_UTF8 6
|
||||
#define CPI_UTF8SIGN 7
|
||||
#define CPI_UTF7 8
|
||||
|
||||
#define IDS_ENCODINGNAME0 61000
|
||||
#define IDS_EOLMODENAME0 62000
|
||||
|
||||
typedef struct _np2encoding {
|
||||
UINT uFlags;
|
||||
UINT uCodePage;
|
||||
char* pszParseNames;
|
||||
int idsName;
|
||||
WCHAR wchLabel[64];
|
||||
} NP2ENCODING;
|
||||
|
||||
int Encoding_CountOf();
|
||||
int Encoding_Current(int); // getter/setter
|
||||
int Encoding_SrcCmdLn(int); // getter/setter
|
||||
int Encoding_SrcWeak(int); // getter/setter
|
||||
BOOL Encoding_HasChanged(int); // query/setter
|
||||
|
||||
void Encoding_InitDefaults();
|
||||
int Encoding_MapIniSetting(BOOL, int);
|
||||
int Encoding_MapUnicode(int);
|
||||
void Encoding_SetLabel(int);
|
||||
int Encoding_MatchW(LPCWSTR);
|
||||
int Encoding_MatchA(char*);
|
||||
BOOL Encoding_IsValid(int);
|
||||
int Encoding_GetByCodePage(UINT);
|
||||
void Encoding_AddToListView(HWND, int, BOOL);
|
||||
BOOL Encoding_GetFromListView(HWND, int *);
|
||||
void Encoding_AddToComboboxEx(HWND, int, BOOL);
|
||||
BOOL Encoding_GetFromComboboxEx(HWND, int *);
|
||||
|
||||
UINT Encoding_GetCodePage(int);
|
||||
|
||||
BOOL Encoding_IsDefault(int);
|
||||
BOOL Encoding_IsANSI(int);
|
||||
BOOL Encoding_IsOEM(int);
|
||||
BOOL Encoding_IsUTF8(int);
|
||||
BOOL Encoding_IsUTF8_SIGN(int);
|
||||
BOOL Encoding_IsMBCS(int);
|
||||
BOOL Encoding_IsUNICODE(int);
|
||||
BOOL Encoding_IsUNICODE_BOM(int);
|
||||
BOOL Encoding_IsUNICODE_REVERSE(int);
|
||||
BOOL Encoding_IsINTERNAL(int);
|
||||
BOOL Encoding_IsEXTERNAL_8BIT(int);
|
||||
BOOL Encoding_IsRECODE(int);
|
||||
|
||||
void Encoding_SetDefaultFlag(int);
|
||||
const WCHAR* Encoding_GetLabel(int);
|
||||
const char* Encoding_GetParseNames(int);
|
||||
|
||||
// Scintilla related
|
||||
UINT Encoding_SciGetCodePage(HWND);
|
||||
int Encoding_SciMappedCodePage(int);
|
||||
void Encoding_SciSetCodePage(HWND, int);
|
||||
|
||||
|
||||
BOOL IsUnicode(const char*, int, LPBOOL, LPBOOL);
|
||||
BOOL IsUTF8(const char*, int);
|
||||
BOOL IsUTF7(const char*, int);
|
||||
|
||||
#define IsUTF8Signature(p) ((*(p+0) == '\xEF' && *(p+1) == '\xBB' && *(p+2) == '\xBF'))
|
||||
#define UTF8StringStart(p) (IsUTF8Signature(p)) ? (p+3) : (p)
|
||||
|
||||
INT UTF8_mbslen_bytes(LPCSTR utf8_string);
|
||||
INT UTF8_mbslen(LPCSTR source, INT byte_length);
|
||||
|
||||
|
||||
int Encoding_GetEncoding(const char* const, const size_t);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif //_NP3_ENCODING_H_
|
||||
882
src/Helpers.c
882
src/Helpers.c
@ -29,21 +29,21 @@
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#include <commctrl.h>
|
||||
#include <uxtheme.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
//#include <pathcch.h>
|
||||
#include "scintilla.h"
|
||||
#include "resource.h"
|
||||
#include "edit.h"
|
||||
#include "encoding.h"
|
||||
#include "notepad3.h"
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
//=============================================================================
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Cut of substrings defined by pattern
|
||||
@ -2756,881 +2756,6 @@ VOID RestoreWndFromTray(HWND hWnd)
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Encoding Helper Functions
|
||||
//
|
||||
|
||||
int g_DOSEncoding;
|
||||
|
||||
// Supported Encodings
|
||||
WCHAR wchANSI[16] = { L'\0' };
|
||||
WCHAR wchOEM[16] = { L'\0' };
|
||||
|
||||
NP2ENCODING g_Encodings[] = {
|
||||
{ NCP_ANSI | NCP_RECODE, CP_ACP, "ansi,system,ascii,", 61000, L"" },
|
||||
{ NCP_OEM | NCP_RECODE, CP_OEMCP, "oem,oem,", 61001, L"" },
|
||||
{ NCP_UNICODE | NCP_UNICODE_BOM, CP_UTF8, "", 61002, L"" },
|
||||
{ NCP_UNICODE | NCP_UNICODE_REVERSE | NCP_UNICODE_BOM, CP_UTF8, "", 61003, L"" },
|
||||
{ NCP_UNICODE | NCP_RECODE, CP_UTF8, "utf-16,utf16,unicode,", 61004, L"" },
|
||||
{ NCP_UNICODE | NCP_UNICODE_REVERSE | NCP_RECODE, CP_UTF8, "utf-16be,utf16be,unicodebe,", 61005, L"" },
|
||||
{ NCP_UTF8 | NCP_RECODE, CP_UTF8, "utf-8,utf8,", 61006, L"" },
|
||||
{ NCP_UTF8 | NCP_UTF8_SIGN, CP_UTF8, "utf-8,utf8,", 61007, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, CP_UTF7, "utf-7,utf7,", 61008, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 720, "DOS-720,dos720,", 61009, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28596, "iso-8859-6,iso88596,arabic,csisolatinarabic,ecma114,isoir127,", 61010, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10004, "x-mac-arabic,xmacarabic,", 61011, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1256, "windows-1256,windows1256,cp1256", 61012, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 775, "ibm775,ibm775,cp500,", 61013, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28594, "iso-8859-4,iso88594,csisolatin4,isoir110,l4,latin4,", 61014, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1257, "windows-1257,windows1257,", 61015, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 852, "ibm852,ibm852,cp852,", 61016, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28592, "iso-8859-2,iso88592,csisolatin2,isoir101,latin2,l2,", 61017, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10029, "x-mac-ce,xmacce,", 61018, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1250, "windows-1250,windows1250,xcp1250,", 61019, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 936, "gb2312,gb2312,chinese,cngb,csgb2312,csgb231280,gb231280,gbk,", 61020, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10008, "x-mac-chinesesimp,xmacchinesesimp,", 61021, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 950, "big5,big5,cnbig5,csbig5,xxbig5,", 61022, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10002, "x-mac-chinesetrad,xmacchinesetrad,", 61023, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10082, "x-mac-croatian,xmaccroatian,", 61024, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 866, "cp866,cp866,ibm866,", 61025, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28595, "iso-8859-5,iso88595,csisolatin5,csisolatincyrillic,cyrillic,isoir144,", 61026, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 20866, "koi8-r,koi8r,cskoi8r,koi,koi8,", 61027, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 21866, "koi8-u,koi8u,koi8ru,", 61028, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10007, "x-mac-cyrillic,xmaccyrillic,", 61029, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1251, "windows-1251,windows1251,xcp1251,", 61030, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28603, "iso-8859-13,iso885913,", 61031, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 863, "ibm863,ibm863,", 61032, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 737, "ibm737,ibm737,", 61033, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28597, "iso-8859-7,iso88597,csisolatingreek,ecma118,elot928,greek,greek8,isoir126,", 61034, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10006, "x-mac-greek,xmacgreek,", 61035, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1253, "windows-1253,windows1253,", 61036, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 869, "ibm869,ibm869,", 61037, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 862, "DOS-862,dos862,", 61038, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 38598, "iso-8859-8-i,iso88598i,logical,", 61039, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28598, "iso-8859-8,iso88598,csisolatinhebrew,hebrew,isoir138,visual,", 61040, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10005, "x-mac-hebrew,xmachebrew,", 61041, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1255, "windows-1255,windows1255,", 61042, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 861, "ibm861,ibm861,", 61043, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10079, "x-mac-icelandic,xmacicelandic,", 61044, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10001, "x-mac-japanese,xmacjapanese,", 61045, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 932, "shift_jis,shiftjis,shiftjs,csshiftjis,cswindows31j,mskanji,xmscp932,xsjis,", 61046, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10003, "x-mac-korean,xmackorean,", 61047, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 949, "windows-949,windows949,ksc56011987,csksc5601,euckr,isoir149,korean,ksc56011989", 61048, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28593, "iso-8859-3,iso88593,latin3,isoir109,l3,", 61049, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28605, "iso-8859-15,iso885915,latin9,l9,", 61050, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 865, "ibm865,ibm865,", 61051, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 437, "ibm437,ibm437,437,cp437,cspc8,codepage437,", 61052, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 858, "ibm858,ibm858,ibm00858,", 61053, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 860, "ibm860,ibm860,", 61054, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10010, "x-mac-romanian,xmacromanian,", 61055, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10021, "x-mac-thai,xmacthai,", 61056, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 874, "windows-874,windows874,dos874,iso885911,tis620,", 61057, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 857, "ibm857,ibm857,", 61058, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28599, "iso-8859-9,iso88599,latin5,isoir148,l5,", 61059, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10081, "x-mac-turkish,xmacturkish,", 61060, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1254, "windows-1254,windows1254,", 61061, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10017, "x-mac-ukrainian,xmacukrainian,", 61062, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1258, "windows-1258,windows-258,", 61063, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 850, "ibm850,ibm850,", 61064, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 28591, "iso-8859-1,iso88591,cp819,latin1,ibm819,isoir100,latin1,l1,", 61065, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 10000, "macintosh,macintosh,", 61066, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1252, "windows-1252,windows1252,cp367,cp819,ibm367,us,xansi,", 61067, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 37, "ebcdic-cp-us,ebcdiccpus,ebcdiccpca,ebcdiccpwt,ebcdiccpnl,ibm037,cp037,", 61068, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 500, "x-ebcdic-international,xebcdicinternational,", 61069, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 875, "x-EBCDIC-GreekModern,xebcdicgreekmodern,", 61070, L"" },
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 1026, "CP1026,cp1026,csibm1026,ibm1026,", 61071, L"" },
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 870, "CP870,cp870,ebcdiccproece,ebcdiccpyu,csibm870,ibm870,", 00000, L"" }, // IBM EBCDIC (Multilingual Latin-2)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1047, "IBM01047,ibm01047,", 00000, L"" }, // IBM EBCDIC (Open System Latin-1)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1140, "x-ebcdic-cp-us-euro,xebcdiccpuseuro,", 00000, L"" }, // IBM EBCDIC (US-Canada-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1141, "x-ebcdic-germany-euro,xebcdicgermanyeuro,", 00000, L"" }, // IBM EBCDIC (Germany-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1142, "x-ebcdic-denmarknorway-euro,xebcdicdenmarknorwayeuro,", 00000, L"" }, // IBM EBCDIC (Denmark-Norway-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1143, "x-ebcdic-finlandsweden-euro,xebcdicfinlandswedeneuro,", 00000, L"" }, // IBM EBCDIC (Finland-Sweden-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1144, "x-ebcdic-italy-euro,xebcdicitalyeuro,", 00000, L"" }, // IBM EBCDIC (Italy-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1145, "x-ebcdic-spain-euro,xebcdicspaineuro,", 00000, L"" }, // IBM EBCDIC (Spain-Latin America-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1146, "x-ebcdic-uk-euro,xebcdicukeuro,", 00000, L"" }, // IBM EBCDIC (UK-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1147, "x-ebcdic-france-euro,xebcdicfranceeuro,", 00000, L"" }, // IBM EBCDIC (France-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1148, "x-ebcdic-international-euro,xebcdicinternationaleuro,", 00000, L"" }, // IBM EBCDIC (International-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1149, "x-ebcdic-icelandic-euro,xebcdicicelandiceuro,", 00000, L"" }, // IBM EBCDIC (Icelandic-Euro)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 1361, "johab,johab,", 00000, L"" }, // Korean (Johab)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20273, "x-EBCDIC-Germany,xebcdicgermany,", 00000, L"" }, // IBM EBCDIC (Germany)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20277, "x-EBCDIC-DenmarkNorway,xebcdicdenmarknorway,ebcdiccpdk,ebcdiccpno,", 00000, L"" }, // IBM EBCDIC (Denmark-Norway)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20278, "x-EBCDIC-FinlandSweden,xebcdicfinlandsweden,ebcdicpfi,ebcdiccpse,", 00000, L"" }, // IBM EBCDIC (Finland-Sweden)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20280, "x-EBCDIC-Italy,xebcdicitaly,", 00000, L"" }, // IBM EBCDIC (Italy)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20284, "x-EBCDIC-Spain,xebcdicspain,ebcdiccpes,", 00000, L"" }, // IBM EBCDIC (Spain-Latin America)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20285, "x-EBCDIC-UK,xebcdicuk,ebcdiccpgb,", 00000, L"" }, // IBM EBCDIC (UK)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20290, "x-EBCDIC-JapaneseKatakana,xebcdicjapanesekatakana,", 00000, L"" }, // IBM EBCDIC (Japanese Katakana)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20297, "x-EBCDIC-France,xebcdicfrance,ebcdiccpfr,", 00000, L"" }, // IBM EBCDIC (France)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20420, "x-EBCDIC-Arabic,xebcdicarabic,ebcdiccpar1,", 00000, L"" }, // IBM EBCDIC (Arabic)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20423, "x-EBCDIC-Greek,xebcdicgreek,ebcdiccpgr,", 00000, L"" }, // IBM EBCDIC (Greek)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20424, "x-EBCDIC-Hebrew,xebcdichebrew,ebcdiccphe,", 00000, L"" }, // IBM EBCDIC (Hebrew)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20833, "x-EBCDIC-KoreanExtended,xebcdickoreanextended,", 00000, L"" }, // IBM EBCDIC (Korean Extended)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20838, "x-EBCDIC-Thai,xebcdicthai,ibmthai,csibmthai,", 00000, L"" }, // IBM EBCDIC (Thai)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20871, "x-EBCDIC-Icelandic,xebcdicicelandic,ebcdiccpis,", 00000, L"" }, // IBM EBCDIC (Icelandic)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20880, "x-EBCDIC-CyrillicRussian,xebcdiccyrillicrussian,ebcdiccyrillic,", 00000, L"" }, // IBM EBCDIC (Cyrillic Russian)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20905, "x-EBCDIC-Turkish,xebcdicturkish,ebcdiccptr,", 00000, L"" }, // IBM EBCDIC (Turkish)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20924, "IBM00924,ibm00924,ebcdiclatin9euro,", 00000, L"" }, // IBM EBCDIC (Open System-Euro Latin-1)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 21025, "x-EBCDIC-CyrillicSerbianBulgarian,xebcdiccyrillicserbianbulgarian,", 00000, L"" }, // IBM EBCDIC (Cyrillic Serbian-Bulgarian)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50930, "x-EBCDIC-JapaneseAndKana,xebcdicjapaneseandkana,", 00000, L"" }, // IBM EBCDIC (Japanese and Japanese Katakana)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50931, "x-EBCDIC-JapaneseAndUSCanada,xebcdicjapaneseanduscanada,", 00000, L"" }, // IBM EBCDIC (Japanese and US-Canada)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50933, "x-EBCDIC-KoreanAndKoreanExtended,xebcdickoreanandkoreanextended,", 00000, L"" }, // IBM EBCDIC (Korean and Korean Extended)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50935, "x-EBCDIC-SimplifiedChinese,xebcdicsimplifiedchinese,", 00000, L"" }, // IBM EBCDIC (Chinese Simplified)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50937, "x-EBCDIC-TraditionalChinese,xebcdictraditionalchinese,", 00000, L"" }, // IBM EBCDIC (Chinese Traditional)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50939, "x-EBCDIC-JapaneseAndJapaneseLatin,xebcdicjapaneseandjapaneselatin,", 00000, L"" }, // IBM EBCDIC (Japanese and Japanese-Latin)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20105, "x-IA5,xia5,", 00000, L"" }, // Western European (IA5)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20106, "x-IA5-German,xia5german,", 00000, L"" }, // German (IA5)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20107, "x-IA5-Swedish,xia5swedish,", 00000, L"" }, // Swedish (IA5)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20108, "x-IA5-Norwegian,xia5norwegian,", 00000, L"" }, // Norwegian (IA5)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20936, "x-cp20936,xcp20936,", 00000, L"" }, // Chinese Simplified (GB2312)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20932, "euc-jp,,", 00000, L"" }, // Japanese (JIS X 0208-1990 & 0212-1990)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50220, "iso-2022-jp,iso2022jp,", 00000, L"" }, // Japanese (JIS)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50221, "csISO2022JP,csiso2022jp,", 00000, L"" }, // Japanese (JIS-Allow 1 byte Kana)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50222, "_iso-2022-jp$SIO,iso2022jpSIO,", 00000, L"" }, // Japanese (JIS-Allow 1 byte Kana - SO/SI)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50225, "iso-2022-kr,iso2022kr,csiso2022kr,", 00000, L"" }, // Korean (ISO-2022-KR)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50227, "x-cp50227,xcp50227,", 00000, L"" }, // Chinese Simplified (ISO-2022)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 50229, "iso-2022-cn,iso2022cn,", 00000, L"" }, // Chinese Traditional (ISO-2022)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20000, "x-Chinese-CNS,xchinesecns,", 00000, L"" }, // Chinese Traditional (CNS)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 20002, "x-Chinese-Eten,xchineseeten,", 00000, L"" }, // Chinese Traditional (Eten)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 51932, "euc-jp,eucjp,xeuc,xeucjp,", 00000, L"" }, // Japanese (EUC)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 51936, "euc-cn,euccn,xeuccn,", 00000, L"" }, // Chinese Simplified (EUC)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 51949, "euc-kr,euckr,cseuckr,", 00000, L"" }, // Korean (EUC)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 52936, "hz-gb-2312,hzgb2312,hz,", 00000, L"" }, // Chinese Simplified (HZ-GB2312)
|
||||
{ NCP_EXTERNAL_8BIT | NCP_RECODE, 54936, "gb18030,gb18030,", 61072, L"" } // Chinese Simplified (GB18030)
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57002, "x-iscii-de,xisciide,", 00000, L"" }, // ISCII Devanagari
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57003, "x-iscii-be,xisciibe,", 00000, L"" }, // ISCII Bengali
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57004, "x-iscii-ta,xisciita,", 00000, L"" }, // ISCII Tamil
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57005, "x-iscii-te,xisciite,", 00000, L"" }, // ISCII Telugu
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57006, "x-iscii-as,xisciias,", 00000, L"" }, // ISCII Assamese
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57007, "x-iscii-or,xisciior,", 00000, L"" }, // ISCII Oriya
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57008, "x-iscii-ka,xisciika,", 00000, L"" }, // ISCII Kannada
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57009, "x-iscii-ma,xisciima,", 00000, L"" }, // ISCII Malayalam
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57010, "x-iscii-gu,xisciigu,", 00000, L"" }, // ISCII Gujarathi
|
||||
//{ NCP_EXTERNAL_8BIT|NCP_RECODE, 57011, "x-iscii-pa,xisciipa,", 00000, L"" }, // ISCII Panjabi
|
||||
};
|
||||
|
||||
int Encoding_CountOf() {
|
||||
return COUNTOF(g_Encodings);
|
||||
}
|
||||
|
||||
int Encoding_Current(int iEncoding) {
|
||||
static int CurrentEncoding = CPI_NONE;
|
||||
|
||||
if (iEncoding >= 0) {
|
||||
if (Encoding_IsValid(iEncoding))
|
||||
CurrentEncoding = iEncoding;
|
||||
else
|
||||
CurrentEncoding = CPI_UTF8;
|
||||
}
|
||||
return CurrentEncoding;
|
||||
}
|
||||
|
||||
|
||||
int Encoding_SrcCmdLn(int iSrcEncoding) {
|
||||
static int SourceEncoding = CPI_NONE;
|
||||
|
||||
if (iSrcEncoding >= 0) {
|
||||
if (Encoding_IsValid(iSrcEncoding))
|
||||
SourceEncoding = iSrcEncoding;
|
||||
else
|
||||
SourceEncoding = CPI_UTF8;
|
||||
}
|
||||
else if (iSrcEncoding == CPI_NONE) {
|
||||
SourceEncoding = CPI_NONE;
|
||||
}
|
||||
return SourceEncoding;
|
||||
}
|
||||
|
||||
|
||||
int Encoding_SrcWeak(int iSrcWeakEnc) {
|
||||
static int SourceWeakEncoding = CPI_NONE;
|
||||
|
||||
if (iSrcWeakEnc >= 0) {
|
||||
if (Encoding_IsValid(iSrcWeakEnc))
|
||||
SourceWeakEncoding = iSrcWeakEnc;
|
||||
else
|
||||
SourceWeakEncoding = CPI_ANSI_DEFAULT;
|
||||
}
|
||||
else if (iSrcWeakEnc == CPI_NONE) {
|
||||
SourceWeakEncoding = CPI_NONE;
|
||||
}
|
||||
return SourceWeakEncoding;
|
||||
}
|
||||
|
||||
|
||||
BOOL Encoding_HasChanged(int iOriginalEncoding) {
|
||||
static int OriginalEncoding = CPI_NONE;
|
||||
|
||||
if (iOriginalEncoding >= CPI_NONE) {
|
||||
OriginalEncoding = iOriginalEncoding;
|
||||
}
|
||||
return (BOOL)(OriginalEncoding != Encoding_Current(CPI_GET));
|
||||
}
|
||||
|
||||
|
||||
void Encoding_InitDefaults() {
|
||||
const UINT uCodePageMBCS[20] = {
|
||||
42, // (Symbol)
|
||||
50220,50221,50222,50225,50227,50229, // (Chinese, Japanese, Korean)
|
||||
54936, // (GB18030)
|
||||
57002,57003,57004,57005,57006,57007,57008,57009,57010,57011, // (ISCII)
|
||||
65000, // (UTF-7)
|
||||
65001 // (UTF-8)
|
||||
};
|
||||
|
||||
g_Encodings[CPI_ANSI_DEFAULT].uCodePage = GetACP(); // set ANSI system CP
|
||||
StringCchPrintf(wchANSI,COUNTOF(wchANSI),L" (CP-%u)",g_Encodings[CPI_ANSI_DEFAULT].uCodePage);
|
||||
|
||||
for (int i = CPI_UTF7 + 1; i < COUNTOF(g_Encodings); ++i) {
|
||||
if (Encoding_IsValid(i) && (g_Encodings[i].uCodePage == g_Encodings[CPI_ANSI_DEFAULT].uCodePage)) {
|
||||
g_Encodings[i].uFlags |= NCP_ANSI;
|
||||
if (g_Encodings[i].uFlags & NCP_EXTERNAL_8BIT)
|
||||
g_Encodings[CPI_ANSI_DEFAULT].uFlags |= NCP_EXTERNAL_8BIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_Encodings[CPI_OEM].uCodePage = GetOEMCP();
|
||||
StringCchPrintf(wchOEM,COUNTOF(wchOEM),L" (CP-%u)",g_Encodings[CPI_OEM].uCodePage);
|
||||
|
||||
for (int i = CPI_UTF7 + 1; i < COUNTOF(g_Encodings); ++i) {
|
||||
if (Encoding_IsValid(i) && (g_Encodings[i].uCodePage == g_Encodings[CPI_OEM].uCodePage)) {
|
||||
g_Encodings[i].uFlags |= NCP_OEM;
|
||||
if (g_Encodings[i].uFlags & NCP_EXTERNAL_8BIT)
|
||||
g_Encodings[CPI_OEM].uFlags |= NCP_EXTERNAL_8BIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// multi byte character sets
|
||||
for (int i = 0; i < COUNTOF(g_Encodings); ++i) {
|
||||
for (int k = 0; k < COUNTOF(uCodePageMBCS); k++) {
|
||||
if (g_Encodings[i].uCodePage == uCodePageMBCS[k]) {
|
||||
g_Encodings[i].uFlags |= NCP_MBCS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_DOSEncoding = CPI_OEM;
|
||||
// Try to set the DOS encoding to DOS-437 if the default OEMCP is not DOS-437
|
||||
if (g_Encodings[g_DOSEncoding].uCodePage != 437) {
|
||||
for (int i = CPI_UTF7 + 1; i < COUNTOF(g_Encodings); ++i) {
|
||||
if (Encoding_IsValid(i) && (g_Encodings[i].uCodePage == 437)) {
|
||||
g_DOSEncoding = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int Encoding_MapIniSetting(BOOL bLoad,int iSetting) {
|
||||
if (bLoad) {
|
||||
switch (iSetting) {
|
||||
case -1: return CPI_NONE;
|
||||
case 0: return CPI_ANSI_DEFAULT;
|
||||
case 1: return CPI_UNICODEBOM;
|
||||
case 2: return CPI_UNICODEBEBOM;
|
||||
case 3: return CPI_UTF8;
|
||||
case 4: return CPI_UTF8SIGN;
|
||||
case 5: return CPI_OEM;
|
||||
case 6: return CPI_UNICODE;
|
||||
case 7: return CPI_UNICODEBE;
|
||||
case 8: return CPI_UTF7;
|
||||
default: {
|
||||
for (int i = CPI_UTF7 + 1; i < COUNTOF(g_Encodings); i++) {
|
||||
if ((g_Encodings[i].uCodePage == (UINT)iSetting) && Encoding_IsValid(i))
|
||||
return(i);
|
||||
}
|
||||
return CPI_ANSI_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (iSetting) {
|
||||
case CPI_NONE: return -1;
|
||||
case CPI_ANSI_DEFAULT: return 0;
|
||||
case CPI_UNICODEBOM: return 1;
|
||||
case CPI_UNICODEBEBOM: return 2;
|
||||
case CPI_UTF8: return 3;
|
||||
case CPI_UTF8SIGN: return 4;
|
||||
case CPI_OEM: return 5;
|
||||
case CPI_UNICODE: return 6;
|
||||
case CPI_UNICODEBE: return 7;
|
||||
case CPI_UTF7: return 8;
|
||||
default: {
|
||||
if (Encoding_IsValid(iSetting))
|
||||
return(g_Encodings[iSetting].uCodePage);
|
||||
else
|
||||
return CPI_ANSI_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Encoding_MapUnicode(int iUni) {
|
||||
|
||||
if (iUni == CPI_UNICODEBOM)
|
||||
return CPI_UNICODE;
|
||||
else if (iUni == CPI_UNICODEBEBOM)
|
||||
return CPI_UNICODEBE;
|
||||
else if (iUni == CPI_UTF8SIGN)
|
||||
return CPI_UTF8;
|
||||
else
|
||||
return iUni;
|
||||
}
|
||||
|
||||
void Encoding_SetLabel(int iEncoding) {
|
||||
if (g_Encodings[iEncoding].wchLabel[0] == L'\0') {
|
||||
WCHAR wch1[128] = { L'\0' };
|
||||
WCHAR wch2[128] = { L'\0' };
|
||||
GetString(g_Encodings[iEncoding].idsName,wch1,COUNTOF(wch1));
|
||||
WCHAR *pwsz = StrChr(wch1,L';');
|
||||
if (pwsz) {
|
||||
pwsz = StrChr(CharNext(pwsz),L';');
|
||||
if (pwsz) {
|
||||
pwsz = CharNext(pwsz);
|
||||
}
|
||||
}
|
||||
if (!pwsz)
|
||||
pwsz = wch1;
|
||||
|
||||
StringCchCopyN(wch2,COUNTOF(wch2),pwsz,COUNTOF(wch1));
|
||||
|
||||
if (Encoding_IsANSI(iEncoding))
|
||||
StringCchCatN(wch2,COUNTOF(wch2),wchANSI,COUNTOF(wchANSI));
|
||||
else if (Encoding_IsOEM(iEncoding))
|
||||
StringCchCatN(wch2,COUNTOF(wch2),wchOEM,COUNTOF(wchOEM));
|
||||
|
||||
StringCchCopyN(g_Encodings[iEncoding].wchLabel,COUNTOF(g_Encodings[iEncoding].wchLabel),
|
||||
wch2,COUNTOF(g_Encodings[iEncoding].wchLabel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int Encoding_MatchW(LPCWSTR pwszTest) {
|
||||
char tchTest[256] = { '\0' };
|
||||
WideCharToMultiByteStrg(CP_ACP,pwszTest,tchTest);
|
||||
return(Encoding_MatchA(tchTest));
|
||||
}
|
||||
|
||||
|
||||
int Encoding_MatchA(char *pchTest) {
|
||||
char chTest[256] = { '\0' };
|
||||
char *pchSrc = pchTest;
|
||||
char *pchDst = chTest;
|
||||
*pchDst++ = ',';
|
||||
while (*pchSrc) {
|
||||
if (IsCharAlphaNumericA(*pchSrc))
|
||||
*pchDst++ = *CharLowerA(pchSrc);
|
||||
pchSrc++;
|
||||
}
|
||||
*pchDst++ = ',';
|
||||
*pchDst = 0;
|
||||
for (int i = 0; i < COUNTOF(g_Encodings); i++) {
|
||||
if (StrStrIA(g_Encodings[i].pszParseNames,chTest)) {
|
||||
CPINFO cpi;
|
||||
if ((g_Encodings[i].uFlags & NCP_INTERNAL) ||
|
||||
IsValidCodePage(g_Encodings[i].uCodePage) &&
|
||||
GetCPInfo(g_Encodings[i].uCodePage,&cpi))
|
||||
return(i);
|
||||
else
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
int Encoding_GetByCodePage(UINT cp) {
|
||||
for (int i = 0; i < COUNTOF(g_Encodings); i++) {
|
||||
if (cp == g_Encodings[i].uCodePage) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return CPI_ANSI_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
BOOL Encoding_IsValid(int iTestEncoding) {
|
||||
CPINFO cpi;
|
||||
if ((iTestEncoding >= 0) && (iTestEncoding < COUNTOF(g_Encodings))) {
|
||||
if ((g_Encodings[iTestEncoding].uFlags & NCP_INTERNAL) ||
|
||||
IsValidCodePage(g_Encodings[iTestEncoding].uCodePage) &&
|
||||
GetCPInfo(g_Encodings[iTestEncoding].uCodePage,&cpi)) {
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
typedef struct _ee {
|
||||
int id;
|
||||
WCHAR wch[256];
|
||||
} ENCODINGENTRY,*PENCODINGENTRY;
|
||||
|
||||
int CmpEncoding(const void *s1,const void *s2) {
|
||||
return StrCmp(((PENCODINGENTRY)s1)->wch,((PENCODINGENTRY)s2)->wch);
|
||||
}
|
||||
|
||||
void Encoding_AddToListView(HWND hwnd,int idSel,BOOL bRecodeOnly) {
|
||||
int i;
|
||||
int iSelItem = -1;
|
||||
LVITEM lvi;
|
||||
WCHAR wchBuf[256] = { L'\0' };
|
||||
|
||||
PENCODINGENTRY pEE = LocalAlloc(LPTR,COUNTOF(g_Encodings) * sizeof(ENCODINGENTRY));
|
||||
for (i = 0; i < COUNTOF(g_Encodings); i++) {
|
||||
pEE[i].id = i;
|
||||
GetString(g_Encodings[i].idsName,pEE[i].wch,COUNTOF(pEE[i].wch));
|
||||
}
|
||||
qsort(pEE,COUNTOF(g_Encodings),sizeof(ENCODINGENTRY),CmpEncoding);
|
||||
|
||||
ZeroMemory(&lvi,sizeof(LVITEM));
|
||||
lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE;
|
||||
lvi.pszText = wchBuf;
|
||||
|
||||
for (i = 0; i < COUNTOF(g_Encodings); i++) {
|
||||
|
||||
int id = pEE[i].id;
|
||||
if (!bRecodeOnly || (g_Encodings[id].uFlags & NCP_RECODE)) {
|
||||
|
||||
lvi.iItem = ListView_GetItemCount(hwnd);
|
||||
|
||||
WCHAR *pwsz = StrChr(pEE[i].wch,L';');
|
||||
if (pwsz) {
|
||||
StringCchCopyN(wchBuf,COUNTOF(wchBuf),CharNext(pwsz),COUNTOF(wchBuf));
|
||||
pwsz = StrChr(wchBuf,L';');
|
||||
if (pwsz)
|
||||
*pwsz = 0;
|
||||
}
|
||||
else
|
||||
StringCchCopyN(wchBuf,COUNTOF(wchBuf),pEE[i].wch,COUNTOF(wchBuf));
|
||||
|
||||
if (Encoding_IsANSI(id))
|
||||
StringCchCatN(wchBuf,COUNTOF(wchBuf),wchANSI,COUNTOF(wchANSI));
|
||||
else if (Encoding_IsOEM(id))
|
||||
StringCchCatN(wchBuf,COUNTOF(wchBuf),wchOEM,COUNTOF(wchOEM));
|
||||
|
||||
if (Encoding_IsValid(id))
|
||||
lvi.iImage = 0;
|
||||
else
|
||||
lvi.iImage = 1;
|
||||
|
||||
lvi.lParam = (LPARAM)id;
|
||||
ListView_InsertItem(hwnd,&lvi);
|
||||
|
||||
if (idSel == id)
|
||||
iSelItem = lvi.iItem;
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(pEE);
|
||||
|
||||
if (iSelItem != -1) {
|
||||
ListView_SetItemState(hwnd,iSelItem,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED);
|
||||
ListView_EnsureVisible(hwnd,iSelItem,FALSE);
|
||||
}
|
||||
else {
|
||||
ListView_SetItemState(hwnd,0,LVIS_FOCUSED,LVIS_FOCUSED);
|
||||
ListView_EnsureVisible(hwnd,0,FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL Encoding_GetFromListView(HWND hwnd,int *pidEncoding) {
|
||||
LVITEM lvi;
|
||||
|
||||
lvi.iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED);
|
||||
lvi.iSubItem = 0;
|
||||
lvi.mask = LVIF_PARAM;
|
||||
|
||||
if (ListView_GetItem(hwnd,&lvi)) {
|
||||
if (Encoding_IsValid((int)lvi.lParam))
|
||||
*pidEncoding = (int)lvi.lParam;
|
||||
else
|
||||
*pidEncoding = -1;
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
void Encoding_AddToComboboxEx(HWND hwnd,int idSel,BOOL bRecodeOnly) {
|
||||
int i;
|
||||
int iSelItem = -1;
|
||||
COMBOBOXEXITEM cbei;
|
||||
WCHAR wchBuf[256] = { L'\0' };
|
||||
|
||||
PENCODINGENTRY pEE = LocalAlloc(LPTR,COUNTOF(g_Encodings) * sizeof(ENCODINGENTRY));
|
||||
for (i = 0; i < COUNTOF(g_Encodings); i++) {
|
||||
pEE[i].id = i;
|
||||
GetString(g_Encodings[i].idsName,pEE[i].wch,COUNTOF(pEE[i].wch));
|
||||
}
|
||||
qsort(pEE,COUNTOF(g_Encodings),sizeof(ENCODINGENTRY),CmpEncoding);
|
||||
|
||||
ZeroMemory(&cbei,sizeof(COMBOBOXEXITEM));
|
||||
cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM;
|
||||
cbei.pszText = wchBuf;
|
||||
cbei.cchTextMax = COUNTOF(wchBuf);
|
||||
cbei.iImage = 0;
|
||||
cbei.iSelectedImage = 0;
|
||||
|
||||
for (i = 0; i < COUNTOF(g_Encodings); i++) {
|
||||
|
||||
int id = pEE[i].id;
|
||||
if (!bRecodeOnly || (g_Encodings[id].uFlags & NCP_RECODE)) {
|
||||
|
||||
cbei.iItem = SendMessage(hwnd,CB_GETCOUNT,0,0);
|
||||
|
||||
WCHAR *pwsz = StrChr(pEE[i].wch,L';');
|
||||
if (pwsz) {
|
||||
StringCchCopyN(wchBuf,COUNTOF(wchBuf),CharNext(pwsz),COUNTOF(wchBuf));
|
||||
pwsz = StrChr(wchBuf,L';');
|
||||
if (pwsz)
|
||||
*pwsz = 0;
|
||||
}
|
||||
else
|
||||
StringCchCopyN(wchBuf,COUNTOF(wchBuf),pEE[i].wch,COUNTOF(wchBuf));
|
||||
|
||||
if (Encoding_IsANSI(id))
|
||||
StringCchCatN(wchBuf,COUNTOF(wchBuf),wchANSI,COUNTOF(wchANSI));
|
||||
else if (id == CPI_OEM)
|
||||
StringCchCatN(wchBuf,COUNTOF(wchBuf),wchOEM,COUNTOF(wchOEM));
|
||||
|
||||
cbei.iImage = (Encoding_IsValid(id) ? 0 : 1);
|
||||
|
||||
cbei.lParam = (LPARAM)id;
|
||||
SendMessage(hwnd,CBEM_INSERTITEM,0,(LPARAM)&cbei);
|
||||
|
||||
if (idSel == id)
|
||||
iSelItem = (int)cbei.iItem;
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(pEE);
|
||||
|
||||
if (iSelItem != -1)
|
||||
SendMessage(hwnd,CB_SETCURSEL,(WPARAM)iSelItem,0);
|
||||
}
|
||||
|
||||
|
||||
BOOL Encoding_GetFromComboboxEx(HWND hwnd,int *pidEncoding) {
|
||||
COMBOBOXEXITEM cbei;
|
||||
|
||||
cbei.iItem = SendMessage(hwnd,CB_GETCURSEL,0,0);
|
||||
cbei.mask = CBEIF_LPARAM;
|
||||
|
||||
if (SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei)) {
|
||||
if (Encoding_IsValid((int)cbei.lParam))
|
||||
*pidEncoding = (int)cbei.lParam;
|
||||
else
|
||||
*pidEncoding = -1;
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOL Encoding_IsDefault(int iEncoding) {
|
||||
return (g_Encodings[iEncoding].uFlags & NCP_DEFAULT);
|
||||
}
|
||||
|
||||
BOOL Encoding_IsANSI(int iEncoding) {
|
||||
return (g_Encodings[iEncoding].uFlags & NCP_ANSI);
|
||||
}
|
||||
|
||||
BOOL Encoding_IsOEM(int iEncoding) {
|
||||
return (g_Encodings[iEncoding].uFlags & NCP_OEM);
|
||||
}
|
||||
|
||||
UINT Encoding_SciGetCodePage(HWND hwnd) {
|
||||
UNUSED(hwnd);
|
||||
return CP_UTF8;
|
||||
// remove internal support for Chinese, Japan, Korean DBCS use UTF-8 instead
|
||||
/*
|
||||
int cp = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0);
|
||||
if (cp == 932 || cp == 936 || cp == 949 || cp == 950) {
|
||||
return cp;
|
||||
}
|
||||
return (cp == 0) ? CP_ACP : CP_UTF8;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
int Encoding_SciMappedCodePage(int iEncoding) {
|
||||
UNUSED(iEncoding);
|
||||
return SC_CP_UTF8;
|
||||
// remove internal support for Chinese, Japan, Korean DBCS use UTF-8 instead
|
||||
/*
|
||||
if (Encoding_IsValid(iEncoding)) {
|
||||
// check for Chinese, Japan, Korean DBCS code pages and switch accordingly
|
||||
int cp = (int)g_Encodings[iEncoding].uCodePage;
|
||||
if (cp == 932 || cp == 936 || cp == 949 || cp == 950) {
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void Encoding_SciSetCodePage(HWND hwnd,int iEncoding) {
|
||||
int cp = Encoding_SciMappedCodePage(iEncoding);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,(WPARAM)cp,0);
|
||||
// charsets can be changed via styles schema
|
||||
/*
|
||||
int charset = SC_CHARSET_ANSI;
|
||||
switch (cp) {
|
||||
case 932:
|
||||
charset = SC_CHARSET_SHIFTJIS;
|
||||
break;
|
||||
case 936:
|
||||
charset = SC_CHARSET_GB2312;
|
||||
break;
|
||||
case 949:
|
||||
charset = SC_CHARSET_HANGUL;
|
||||
break;
|
||||
case 950:
|
||||
charset = SC_CHARSET_CHINESEBIG5;
|
||||
break;
|
||||
default:
|
||||
charset = g_iDefaultCharSet;
|
||||
break;
|
||||
}
|
||||
SendMessage(hwnd,SCI_STYLESETCHARACTERSET,(WPARAM)STYLE_DEFAULT,(LPARAM)charset);
|
||||
*/
|
||||
}
|
||||
|
||||
extern BOOL bSkipUnicodeDetection;
|
||||
|
||||
BOOL IsUnicode(const char* pBuffer,int cb,LPBOOL lpbBOM,LPBOOL lpbReverse) {
|
||||
int i = 0xFFFF;
|
||||
|
||||
BOOL bIsTextUnicode;
|
||||
|
||||
BOOL bHasBOM;
|
||||
BOOL bHasRBOM;
|
||||
|
||||
if (!pBuffer || cb < 2)
|
||||
return FALSE;
|
||||
|
||||
if (!bSkipUnicodeDetection)
|
||||
bIsTextUnicode = IsTextUnicode(pBuffer,cb,&i);
|
||||
else
|
||||
bIsTextUnicode = FALSE;
|
||||
|
||||
bHasBOM = (*((UNALIGNED PWCHAR)pBuffer) == 0xFEFF);
|
||||
bHasRBOM = (*((UNALIGNED PWCHAR)pBuffer) == 0xFFFE);
|
||||
|
||||
if (i == 0xFFFF) // i doesn't seem to have been modified ...
|
||||
i = 0;
|
||||
|
||||
if (bIsTextUnicode || bHasBOM || bHasRBOM ||
|
||||
((i & (IS_TEXT_UNICODE_UNICODE_MASK | IS_TEXT_UNICODE_REVERSE_MASK)) &&
|
||||
!((i & IS_TEXT_UNICODE_UNICODE_MASK) && (i & IS_TEXT_UNICODE_REVERSE_MASK)) &&
|
||||
!(i & IS_TEXT_UNICODE_ODD_LENGTH) &&
|
||||
!(i & IS_TEXT_UNICODE_ILLEGAL_CHARS && !(i & IS_TEXT_UNICODE_REVERSE_SIGNATURE)) &&
|
||||
!((i & IS_TEXT_UNICODE_REVERSE_MASK) == IS_TEXT_UNICODE_REVERSE_STATISTICS))) {
|
||||
|
||||
if (lpbBOM)
|
||||
*lpbBOM = (bHasBOM || bHasRBOM ||
|
||||
(i & (IS_TEXT_UNICODE_SIGNATURE | IS_TEXT_UNICODE_REVERSE_SIGNATURE)))
|
||||
? TRUE : FALSE;
|
||||
|
||||
if (lpbReverse)
|
||||
*lpbReverse = (bHasRBOM || (i & IS_TEXT_UNICODE_REVERSE_MASK)) ? TRUE : FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL IsUTF8(const char* pTest,int nLength) {
|
||||
static int byte_class_table[256] = {
|
||||
/* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */
|
||||
/* 00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 80 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
/* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
/* A0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
/* B0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
/* C0 */ 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
/* D0 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
/* E0 */ 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7,
|
||||
/* F0 */ 9,10,10,10,11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
|
||||
/* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ };
|
||||
|
||||
/* state table */
|
||||
typedef enum {
|
||||
kSTART = 0,kA,kB,kC,kD,kE,kF,kG,kERROR,kNumOfStates
|
||||
} utf8_state;
|
||||
|
||||
static utf8_state state_table[] = {
|
||||
/* kSTART, kA, kB, kC, kD, kE, kF, kG, kERROR */
|
||||
/* 0x00-0x7F: 0 */ kSTART, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
|
||||
/* 0x80-0x8F: 1 */ kERROR, kSTART, kA, kERROR, kA, kB, kERROR, kB, kERROR,
|
||||
/* 0x90-0x9f: 2 */ kERROR, kSTART, kA, kERROR, kA, kB, kB, kERROR, kERROR,
|
||||
/* 0xa0-0xbf: 3 */ kERROR, kSTART, kA, kA, kERROR, kB, kB, kERROR, kERROR,
|
||||
/* 0xc0-0xc1, 0xf5-0xff: 4 */ kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
|
||||
/* 0xc2-0xdf: 5 */ kA, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
|
||||
/* 0xe0: 6 */ kC, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
|
||||
/* 0xe1-0xec, 0xee-0xef: 7 */ kB, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
|
||||
/* 0xed: 8 */ kD, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
|
||||
/* 0xf0: 9 */ kF, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
|
||||
/* 0xf1-0xf3: 10 */ kE, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
|
||||
/* 0xf4: 11 */ kG, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR };
|
||||
|
||||
#define BYTE_CLASS(b) (byte_class_table[(unsigned char)b])
|
||||
#define NEXT_STATE(b,cur) (state_table[(BYTE_CLASS(b) * kNumOfStates) + (cur)])
|
||||
|
||||
utf8_state current = kSTART;
|
||||
int i;
|
||||
|
||||
const char* pt = pTest;
|
||||
int len = nLength;
|
||||
|
||||
for (i = 0; i < len; i++,pt++) {
|
||||
|
||||
current = NEXT_STATE(*pt,current);
|
||||
if (kERROR == current)
|
||||
break;
|
||||
}
|
||||
|
||||
return (current == kSTART) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL IsUTF7(const char* pTest,int nLength) {
|
||||
int i;
|
||||
const char *pt = pTest;
|
||||
|
||||
for (i = 0; i < nLength; i++) {
|
||||
if (*pt & 0x80 || !*pt)
|
||||
return FALSE;
|
||||
pt++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* byte length of UTF-8 sequence based on value of first byte.
|
||||
for UTF-16 (21-bit space), max. code length is 4, so we only need to look
|
||||
at 4 upper bits.
|
||||
*/
|
||||
static const INT utf8_lengths[16] =
|
||||
{
|
||||
1,1,1,1,1,1,1,1, /* 0000 to 0111 : 1 byte (plain ASCII) */
|
||||
0,0,0,0, /* 1000 to 1011 : not valid */
|
||||
2,2, /* 1100, 1101 : 2 bytes */
|
||||
3, /* 1110 : 3 bytes */
|
||||
4 /* 1111 :4 bytes */
|
||||
};
|
||||
|
||||
/*++
|
||||
Function :
|
||||
UTF8_mbslen_bytes [INTERNAL]
|
||||
|
||||
Calculates the byte size of a NULL-terminated UTF-8 string.
|
||||
|
||||
Parameters :
|
||||
char *utf8_string : string to examine
|
||||
|
||||
Return value :
|
||||
size (in bytes) of a NULL-terminated UTF-8 string.
|
||||
-1 if invalid NULL-terminated UTF-8 string
|
||||
--*/
|
||||
INT UTF8_mbslen_bytes(LPCSTR utf8_string)
|
||||
{
|
||||
INT length = 0;
|
||||
INT code_size;
|
||||
BYTE byte;
|
||||
|
||||
while (*utf8_string) {
|
||||
byte = (BYTE)*utf8_string;
|
||||
|
||||
if ((byte <= 0xF7) && (0 != (code_size = utf8_lengths[byte >> 4]))) {
|
||||
length += code_size;
|
||||
utf8_string += code_size;
|
||||
}
|
||||
else {
|
||||
/* we got an invalid byte value but need to count it,
|
||||
it will be later ignored during the string conversion */
|
||||
//WARN("invalid first byte value 0x%02X in UTF-8 sequence!\n",byte);
|
||||
length++;
|
||||
utf8_string++;
|
||||
}
|
||||
}
|
||||
length++; /* include NULL terminator */
|
||||
return length;
|
||||
}
|
||||
|
||||
/*++
|
||||
Function :
|
||||
UTF8_mbslen [INTERNAL]
|
||||
|
||||
Calculates the character size of a NULL-terminated UTF-8 string.
|
||||
|
||||
Parameters :
|
||||
char *utf8_string : string to examine
|
||||
int byte_length : byte size of string
|
||||
|
||||
Return value :
|
||||
size (in characters) of a UTF-8 string.
|
||||
-1 if invalid UTF-8 string
|
||||
--*/
|
||||
INT UTF8_mbslen(LPCSTR source,INT byte_length)
|
||||
{
|
||||
INT wchar_length = 0;
|
||||
INT code_size;
|
||||
BYTE byte;
|
||||
|
||||
while (byte_length > 0) {
|
||||
byte = (BYTE)*source;
|
||||
|
||||
/* UTF-16 can't encode 5-byte and 6-byte sequences, so maximum value
|
||||
for first byte is 11110111. Use lookup table to determine sequence
|
||||
length based on upper 4 bits of first byte */
|
||||
if ((byte <= 0xF7) && (0 != (code_size = utf8_lengths[byte >> 4]))) {
|
||||
/* 1 sequence == 1 character */
|
||||
wchar_length++;
|
||||
|
||||
if (code_size == 4)
|
||||
wchar_length++;
|
||||
|
||||
source += code_size; /* increment pointer */
|
||||
byte_length -= code_size; /* decrement counter*/
|
||||
}
|
||||
else {
|
||||
/*
|
||||
unlike UTF8_mbslen_bytes, we ignore the invalid characters.
|
||||
we only report the number of valid characters we have encountered
|
||||
to match the Windows behavior.
|
||||
*/
|
||||
//WARN("invalid byte 0x%02X in UTF-8 sequence, skipping it!\n",
|
||||
// byte);
|
||||
source++;
|
||||
byte_length--;
|
||||
}
|
||||
}
|
||||
return wchar_length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Is the character an octal digit?
|
||||
@ -3641,7 +2766,6 @@ static BOOL IsDigit(WCHAR wch)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// UrlUnescapeEx()
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include <strsafe.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include "TypeDefs.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@ -164,6 +164,7 @@ BOOL IsCmdEnabled(HWND, UINT);
|
||||
|
||||
#define DialogEnableWindow(hdlg, id, b) { HWND hctrl = GetDlgItem((hdlg),(id)); if (!(b)) { \
|
||||
if (GetFocus() == hctrl) { SendMessage((hdlg), WM_NEXTDLGCTL, 0, FALSE); } }; EnableWindow(hctrl, (b)); }
|
||||
|
||||
#define GetString(id,pb,cb) LoadString(g_hInstance,id,pb,cb)
|
||||
|
||||
#define StrEnd(pStart) (pStart + lstrlen(pStart))
|
||||
@ -347,84 +348,6 @@ inline int _StringCchCmpINW(PCNZWCH s1,int l1,PCNZWCH s2,int l2) {
|
||||
#define StringCchCompareIX(s1,s2) StringCchCompareIXA((s1),(s2))
|
||||
#endif
|
||||
|
||||
// ===== File Encoding =====
|
||||
|
||||
extern int g_DOSEncoding;
|
||||
|
||||
#define NCP_DEFAULT 1
|
||||
#define NCP_UTF8 2
|
||||
#define NCP_UTF8_SIGN 4
|
||||
#define NCP_UNICODE 8
|
||||
#define NCP_UNICODE_REVERSE 16
|
||||
#define NCP_UNICODE_BOM 32
|
||||
#define NCP_ANSI 64
|
||||
#define NCP_OEM 128
|
||||
#define NCP_MBCS 256
|
||||
#define NCP_INTERNAL (NCP_DEFAULT|NCP_UTF8|NCP_UTF8_SIGN|NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM|NCP_ANSI|NCP_OEM|NCP_MBCS)
|
||||
#define NCP_EXTERNAL_8BIT 512
|
||||
#define NCP_RECODE 1024
|
||||
|
||||
#define CPI_GET -2
|
||||
#define CPI_NONE -1
|
||||
#define CPI_ANSI_DEFAULT 0
|
||||
#define CPI_OEM 1
|
||||
#define CPI_UNICODEBOM 2
|
||||
#define CPI_UNICODEBEBOM 3
|
||||
#define CPI_UNICODE 4
|
||||
#define CPI_UNICODEBE 5
|
||||
#define CPI_UTF8 6
|
||||
#define CPI_UTF8SIGN 7
|
||||
#define CPI_UTF7 8
|
||||
|
||||
#define IDS_ENCODINGNAME0 61000
|
||||
#define IDS_EOLMODENAME0 62000
|
||||
|
||||
typedef struct _np2encoding {
|
||||
UINT uFlags;
|
||||
UINT uCodePage;
|
||||
char* pszParseNames;
|
||||
int idsName;
|
||||
WCHAR wchLabel[64];
|
||||
} NP2ENCODING;
|
||||
|
||||
int Encoding_CountOf();
|
||||
int Encoding_Current(int); // getter/setter
|
||||
int Encoding_SrcCmdLn(int); // getter/setter
|
||||
int Encoding_SrcWeak(int); // getter/setter
|
||||
BOOL Encoding_HasChanged(int); // query/setter
|
||||
|
||||
void Encoding_InitDefaults();
|
||||
int Encoding_MapIniSetting(BOOL,int);
|
||||
int Encoding_MapUnicode(int);
|
||||
void Encoding_SetLabel(int);
|
||||
int Encoding_MatchW(LPCWSTR);
|
||||
int Encoding_MatchA(char*);
|
||||
BOOL Encoding_IsValid(int);
|
||||
int Encoding_GetByCodePage(UINT);
|
||||
void Encoding_AddToListView(HWND,int,BOOL);
|
||||
BOOL Encoding_GetFromListView(HWND,int *);
|
||||
void Encoding_AddToComboboxEx(HWND,int,BOOL);
|
||||
BOOL Encoding_GetFromComboboxEx(HWND,int *);
|
||||
BOOL Encoding_IsDefault(int);
|
||||
BOOL Encoding_IsANSI(int);
|
||||
BOOL Encoding_IsOEM(int);
|
||||
|
||||
UINT Encoding_SciGetCodePage(HWND);
|
||||
int Encoding_SciMappedCodePage(int);
|
||||
void Encoding_SciSetCodePage(HWND,int);
|
||||
|
||||
|
||||
BOOL IsUnicode(const char*,int,LPBOOL,LPBOOL);
|
||||
BOOL IsUTF8(const char*,int);
|
||||
BOOL IsUTF7(const char*,int);
|
||||
|
||||
#define IsUTF8Signature(p) ((*(p+0) == '\xEF' && *(p+1) == '\xBB' && *(p+2) == '\xBF'))
|
||||
#define UTF8StringStart(p) (IsUTF8Signature(p)) ? (p+3) : (p)
|
||||
|
||||
INT UTF8_mbslen_bytes(LPCSTR utf8_string);
|
||||
INT UTF8_mbslen(LPCSTR source,INT byte_length);
|
||||
|
||||
|
||||
void UrlUnescapeEx(LPWSTR, LPWSTR, DWORD*);
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include <string.h>
|
||||
//#include <pathcch.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "scintilla.h"
|
||||
#include "scilexer.h"
|
||||
#include "edit.h"
|
||||
@ -43,10 +44,13 @@
|
||||
#include "resource.h"
|
||||
#include "../crypto/crypto.h"
|
||||
#include "../uthash/utarray.h"
|
||||
#include "encoding.h"
|
||||
#include "helpers.h"
|
||||
#include "notepad3.h"
|
||||
#include "SciCall.h"
|
||||
|
||||
#include "notepad3.h"
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
@ -288,8 +292,6 @@ EDITFINDREPLACE g_efrData = EFR_INIT_DATA;
|
||||
UINT cpLastFind = 0;
|
||||
BOOL bReplaceInitialized = FALSE;
|
||||
|
||||
extern NP2ENCODING g_Encodings[];
|
||||
|
||||
int iLineEndings[3] = {
|
||||
SC_EOL_CRLF,
|
||||
SC_EOL_LF,
|
||||
@ -2111,15 +2113,15 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
|
||||
EnableCmd(hmenu,IDM_ENCODING_RECODE,i);
|
||||
|
||||
if (g_Encodings[Encoding_Current(CPI_GET)].uFlags & NCP_UNICODE_REVERSE)
|
||||
if (Encoding_IsUNICODE_REVERSE(Encoding_Current(CPI_GET)))
|
||||
i = IDM_ENCODING_UNICODEREV;
|
||||
else if (g_Encodings[Encoding_Current(CPI_GET)].uFlags & NCP_UNICODE)
|
||||
else if (Encoding_IsUNICODE(Encoding_Current(CPI_GET)))
|
||||
i = IDM_ENCODING_UNICODE;
|
||||
else if (g_Encodings[Encoding_Current(CPI_GET)].uFlags & NCP_UTF8_SIGN)
|
||||
else if (Encoding_IsUTF8_SIGN(Encoding_Current(CPI_GET)))
|
||||
i = IDM_ENCODING_UTF8SIGN;
|
||||
else if (g_Encodings[Encoding_Current(CPI_GET)].uFlags & NCP_UTF8)
|
||||
else if (Encoding_IsUTF8(Encoding_Current(CPI_GET)))
|
||||
i = IDM_ENCODING_UTF8;
|
||||
else if (g_Encodings[Encoding_Current(CPI_GET)].uFlags & NCP_ANSI)
|
||||
else if (Encoding_IsANSI(Encoding_Current(CPI_GET)))
|
||||
i = IDM_ENCODING_ANSI;
|
||||
else
|
||||
i = -1;
|
||||
@ -2222,7 +2224,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
i == SCLEX_AU3 || i == SCLEX_LATEX || i == SCLEX_AHK || i == SCLEX_RUBY || i == SCLEX_CMAKE || i == SCLEX_MARKDOWN ||
|
||||
i == SCLEX_YAML || i == SCLEX_REGISTRY || i == SCLEX_NIMROD));
|
||||
|
||||
EnableCmd(hmenu,IDM_EDIT_INSERT_ENCODING,*g_Encodings[Encoding_Current(CPI_GET)].pszParseNames);
|
||||
EnableCmd(hmenu,IDM_EDIT_INSERT_ENCODING, *Encoding_GetParseNames(Encoding_Current(CPI_GET)));
|
||||
|
||||
//EnableCmd(hmenu,IDM_EDIT_INSERT_SHORTDATE,!bReadOnly);
|
||||
//EnableCmd(hmenu,IDM_EDIT_INSERT_LONGDATE,!bReadOnly);
|
||||
@ -3335,10 +3337,10 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDM_EDIT_INSERT_ENCODING:
|
||||
{
|
||||
if (*g_Encodings[Encoding_Current(CPI_GET)].pszParseNames) {
|
||||
if (*Encoding_GetParseNames(Encoding_Current(CPI_GET))) {
|
||||
char msz[32] = { '\0' };
|
||||
//int iSelStart;
|
||||
StringCchCopyNA(msz,COUNTOF(msz),g_Encodings[Encoding_Current(CPI_GET)].pszParseNames,COUNTOF(msz));
|
||||
StringCchCopyNA(msz,COUNTOF(msz), Encoding_GetParseNames(Encoding_Current(CPI_GET)),COUNTOF(msz));
|
||||
char *p = StrChrA(msz, ',');
|
||||
if (p)
|
||||
*p = 0;
|
||||
@ -6018,7 +6020,7 @@ void LoadSettings()
|
||||
*/
|
||||
|
||||
// set flag for encoding default
|
||||
g_Encodings[g_iDefaultNewFileEncoding].uFlags |= NCP_DEFAULT;
|
||||
Encoding_SetDefaultFlag(g_iDefaultNewFileEncoding);
|
||||
|
||||
// define default charset
|
||||
g_iDefaultCharSet = (int)CharSetFromCodePage((UINT)iSciDefaultCodePage);
|
||||
@ -7057,7 +7059,7 @@ void UpdateStatusbar()
|
||||
FormatString(tchDocSize, COUNTOF(tchDocSize), IDS_DOCSIZE, tchBytes);
|
||||
|
||||
Encoding_SetLabel(iEncoding);
|
||||
StringCchPrintf(tchEncoding, COUNTOF(tchEncoding), L" %s ", g_Encodings[iEncoding].wchLabel);
|
||||
StringCchPrintf(tchEncoding, COUNTOF(tchEncoding), L" %s ", Encoding_GetLabel(iEncoding));
|
||||
|
||||
if (g_iEOLMode == SC_EOL_CR)
|
||||
{
|
||||
|
||||
@ -321,6 +321,7 @@
|
||||
<ClCompile Include="Dialogs.c" />
|
||||
<ClCompile Include="Dlapi.c" />
|
||||
<ClCompile Include="Edit.c" />
|
||||
<ClCompile Include="Encoding.c" />
|
||||
<ClCompile Include="Helpers.c" />
|
||||
<ClCompile Include="Notepad3.c" />
|
||||
<ClCompile Include="Print.cpp" />
|
||||
@ -334,6 +335,7 @@
|
||||
<ClInclude Include="Dialogs.h" />
|
||||
<ClInclude Include="Dlapi.h" />
|
||||
<ClInclude Include="Edit.h" />
|
||||
<ClInclude Include="Encoding.h" />
|
||||
<ClInclude Include="Helpers.h" />
|
||||
<ClInclude Include="Notepad3.h" />
|
||||
<ClInclude Include="SciCall.h" />
|
||||
|
||||
@ -54,6 +54,9 @@
|
||||
<ClCompile Include="..\crypto\sha-256.c">
|
||||
<Filter>Crypto</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Encoding.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Dialogs.h">
|
||||
@ -101,6 +104,9 @@
|
||||
<ClInclude Include="TypeDefs.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Encoding.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\res\Copy.cur">
|
||||
|
||||
@ -6,9 +6,10 @@
|
||||
* Print.cpp *
|
||||
* Scintilla Printing Functionality *
|
||||
* Based on code from Notepad2, (c) Florian Balmer 1996-2011 *
|
||||
* Mostly taken from SciTE, (c) Neil Hodgson *
|
||||
* *
|
||||
* (c) Rizonesoft 2008-2016 *
|
||||
* Mostly taken from SciTE, (c) Neil Hodgson *
|
||||
* *
|
||||
* (c) Rizonesoft 2015-2018 *
|
||||
* https://rizonesoft.com *
|
||||
* *
|
||||
* *
|
||||
@ -34,6 +35,7 @@
|
||||
#include "scintilla.h"
|
||||
#include "scilexer.h"
|
||||
#include "resource.h"
|
||||
|
||||
extern "C" {
|
||||
#include "dialogs.h"
|
||||
#include "helpers.h"
|
||||
|
||||
@ -30,16 +30,18 @@
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "scintilla.h"
|
||||
#include "scilexer.h"
|
||||
#include "notepad3.h"
|
||||
#include "edit.h"
|
||||
#include "dialogs.h"
|
||||
#include "resource.h"
|
||||
#include "encoding.h"
|
||||
#include "helpers.h"
|
||||
#include "styles.h"
|
||||
#include "SciCall.h"
|
||||
|
||||
#include "styles.h"
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user