mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-17 21:03:19 +08:00
Merge pull request #1746 from RaiKoHoff/Dev_UTF-8
ANSI encoding as default: use parent process's console code-page for encoding
This commit is contained in:
commit
670d087aad
@ -1 +1 @@
|
||||
2665
|
||||
2666
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<assemblyIdentity
|
||||
name="Notepad3"
|
||||
processorArchitecture="*"
|
||||
version="5.19.1102.2665"
|
||||
version="5.19.1104.2666"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Notepad3 BETA</description>
|
||||
|
||||
@ -113,10 +113,10 @@ void Encoding_InitDefaults()
|
||||
65001 // (UTF-8)
|
||||
};
|
||||
|
||||
UINT const ansiInputCP = GetACP();
|
||||
ChangeEncodingCodePage(CPI_ANSI_DEFAULT, ansiInputCP); // set ANSI system CP ()
|
||||
assert(g_Encodings[CPI_ANSI_DEFAULT].uCodePage == ansiInputCP);
|
||||
StringCchPrintf(wchANSI, COUNTOF(wchANSI), L" (CP-%u)", ansiInputCP);
|
||||
UINT const ansiCP = CodePageFromCharSet(ANSI_CHARSET);
|
||||
ChangeEncodingCodePage(CPI_ANSI_DEFAULT, ansiCP); // set ANSI system CP ()
|
||||
assert(g_Encodings[CPI_ANSI_DEFAULT].uCodePage == ansiCP);
|
||||
StringCchPrintf(wchANSI, COUNTOF(wchANSI), L" (CP-%u)", ansiCP);
|
||||
|
||||
Globals.bIsCJKInputCodePage = IsDBCSCodePage(Scintilla_InputCodePage());
|
||||
|
||||
|
||||
@ -1430,13 +1430,24 @@ LRESULT ComboBox_AddStringMB2W(HWND hwnd, LPCSTR lpString)
|
||||
//
|
||||
// CodePageFromCharSet()
|
||||
//
|
||||
UINT CodePageFromCharSet(UINT uCharSet)
|
||||
UINT CodePageFromCharSet(const UINT uCharSet)
|
||||
{
|
||||
CHARSETINFO ci;
|
||||
if (TranslateCharsetInfo((DWORD*)(UINT_PTR)uCharSet, &ci, TCI_SRCCHARSET)) {
|
||||
return(ci.ciACP);
|
||||
if (ANSI_CHARSET == uCharSet) {
|
||||
if (Globals.uConsoleCodePage != 0) {
|
||||
return Globals.uConsoleCodePage;
|
||||
}
|
||||
CPINFOEX cpinfo; ZeroMemory(&cpinfo, sizeof(CPINFOEX));
|
||||
if (GetCPInfoEx(CP_THREAD_ACP, 0, &cpinfo)) {
|
||||
return cpinfo.CodePage;
|
||||
}
|
||||
}
|
||||
return(GetACP());
|
||||
else {
|
||||
CHARSETINFO ci; ZeroMemory(&ci, sizeof(CHARSETINFO));
|
||||
if (TranslateCharsetInfo((DWORD*)(UINT_PTR)uCharSet, &ci, TCI_SRCCHARSET)) {
|
||||
return(ci.ciACP);
|
||||
}
|
||||
}
|
||||
return GetACP(); // fallback: systems locale ANSI CP
|
||||
}
|
||||
|
||||
|
||||
@ -1444,7 +1455,7 @@ UINT CodePageFromCharSet(UINT uCharSet)
|
||||
//
|
||||
// CharSetFromCodePage()
|
||||
//
|
||||
UINT CharSetFromCodePage(UINT uCodePage) {
|
||||
UINT CharSetFromCodePage(const UINT uCodePage) {
|
||||
CHARSETINFO ci;
|
||||
if (TranslateCharsetInfo((DWORD*)(UINT_PTR)uCodePage, &ci, TCI_SRCCODEPAGE)) {
|
||||
return(ci.ciCharset); // corresponds to SCI: SC_CHARSET_XXX
|
||||
|
||||
@ -331,8 +331,8 @@ UINT SetDlgItemTextMB2W(HWND hDlg,int nIDDlgItem,LPSTR lpString);
|
||||
LRESULT ComboBox_AddStringMB2W(HWND hwnd,LPCSTR lpString);
|
||||
|
||||
|
||||
UINT CodePageFromCharSet(UINT uCharSet);
|
||||
UINT CharSetFromCodePage(UINT uCodePage);
|
||||
UINT CodePageFromCharSet(const UINT uCharSet);
|
||||
UINT CharSetFromCodePage(const UINT uCodePage);
|
||||
|
||||
|
||||
//==== UnSlash Functions ======================================================
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/******************************************************************************
|
||||
/******************************************************************************
|
||||
* *
|
||||
* *
|
||||
* Notepad3 *
|
||||
@ -96,7 +96,6 @@ int s_flagShellUseSystemMRU = 0;
|
||||
int s_flagPrintFileAndLeave = 0;
|
||||
bool s_flagDoRelaunchElevated = false;
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
static WCHAR s_wchWndClass[16] = _W(SAPPNAME);
|
||||
@ -629,6 +628,7 @@ static void _InitGlobals()
|
||||
Globals.pMRUfind = NULL;
|
||||
Globals.pMRUreplace = NULL;
|
||||
Globals.CallTipType = CT_NONE;
|
||||
Globals.uConsoleCodePage = 0;
|
||||
Globals.iAvailLngCount = 1;
|
||||
Globals.iWrapCol = 0;
|
||||
Globals.bForceReLoadAsUTF8 = false;
|
||||
@ -781,6 +781,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
{
|
||||
_InitGlobals();
|
||||
|
||||
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
|
||||
Globals.uConsoleCodePage = GetConsoleCP();
|
||||
FreeConsole();
|
||||
}
|
||||
|
||||
// Set global variable Globals.hInstance
|
||||
Globals.hInstance = hInstance;
|
||||
Globals.hPrevInst = hPrevInstance;
|
||||
|
||||
@ -294,6 +294,7 @@ typedef struct _globals_t
|
||||
bool bPrefLngNotAvail;
|
||||
HWND hwndMain;
|
||||
HANDLE hndlProcessHeap;
|
||||
UINT uConsoleCodePage;
|
||||
HWND hwndEdit;
|
||||
HANDLE hndlScintilla;
|
||||
HANDLE hwndToolbar;
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
#define SAPPNAME "Notepad3"
|
||||
#define VERSION_MAJOR 5
|
||||
#define VERSION_MINOR 19
|
||||
#define VERSION_REV 1102
|
||||
#define VERSION_BUILD 2665
|
||||
#define VERSION_REV 1104
|
||||
#define VERSION_BUILD 2666
|
||||
#define SCINTILLA_VER 420
|
||||
#define ONIGURUMA_REGEX_VER 6.9.4
|
||||
#define UCHARDET_VER 2018.09.27
|
||||
|
||||
Loading…
Reference in New Issue
Block a user