[NEW] Add Chinese simplified, Japanese, Korean, Thai... encodings.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@565 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2009-11-20 00:26:38 +00:00
parent fe4c746cd4
commit 90f5338cb5
6 changed files with 94 additions and 26 deletions

View File

@ -181,40 +181,40 @@ int getCpFromStringValue(const char * encodingStr)
return CP_ACP;
if (stricmp("windows-1250", encodingStr) == 0)
return 1250;
return NPP_CP_WIN_1250;
if (stricmp("windows-1251", encodingStr) == 0)
return 1251;
return NPP_CP_WIN_1251;
if (stricmp("windows-1252", encodingStr) == 0)
return 1252;
return NPP_CP_WIN_1252;
if (stricmp("windows-1253", encodingStr) == 0)
return 1253;
return NPP_CP_WIN_1253;
if (stricmp("windows-1254", encodingStr) == 0)
return 1254;
return NPP_CP_WIN_1254;
if (stricmp("windows-1255", encodingStr) == 0)
return 1255;
return NPP_CP_WIN_1255;
if (stricmp("windows-1256", encodingStr) == 0)
return 1256;
return NPP_CP_WIN_1256;
if (stricmp("windows-1257", encodingStr) == 0)
return 1257;
return NPP_CP_WIN_1257;
if (stricmp("windows-1258", encodingStr) == 0)
return 1258;
return NPP_CP_WIN_1258;
if (stricmp("big5", encodingStr) == 0)
return 950;
return NPP_CP_BIG5;
if (stricmp("gb2312", encodingStr) == 0)
return 936;
return NPP_CP_GB2312;
if (stricmp("shift_jis", encodingStr) == 0)
return 932;
return NPP_CP_SHIFT_JIS;
if (stricmp("euc-kr", encodingStr) == 0)
return 51949;
return NPP_CP_EUC_KR;
if (stricmp("tis-620", encodingStr) == 0)
return 874;
return NPP_CP_TIS_620;
if (stricmp("iso-8859-8", encodingStr) == 0)
return 28598;
return NPP_CP_ISO_8859_8;
if (stricmp("utf-8", encodingStr) == 0)
return 65001;
return CP_UTF8;
return CP_ACP;
}

View File

@ -18,8 +18,28 @@
#ifndef M30_IDE_COMMUN_H
#define M30_IDE_COMMUN_H
#define CP_ANSI_LATIN_1 1252
#define CP_BIG5 950
#define NPP_CP_WIN_1250 1250
#define NPP_CP_WIN_1251 1251
#define NPP_CP_WIN_1252 1252
#define NPP_CP_WIN_1253 1253
#define NPP_CP_WIN_1254 1254
#define NPP_CP_WIN_1255 1255
#define NPP_CP_WIN_1256 1256
#define NPP_CP_WIN_1257 1257
#define NPP_CP_WIN_1258 1258
#define NPP_CP_BIG5 950
#define NPP_CP_EUC_KR 51949
#define NPP_CP_SHIFT_JIS 932
#define NPP_CP_GB2312 936
#define NPP_CP_ISO_8859_8 28598
#define NPP_CP_TIS_620 874
#ifdef UNICODE
#define NppMainEntry wWinMain

View File

@ -4371,14 +4371,41 @@ void Notepad_plus::command(int id)
}
break;
}
case IDM_FORMAT_WIN1250 :
case IDM_FORMAT_WIN1253 :
case IDM_FORMAT_WIN1256 :
case IDM_FORMAT_TIS_620 :
case IDM_FORMAT_GB2312 :
case IDM_FORMAT_SHIFT_JIS :
case IDM_FORMAT_EUC_KR :
case IDM_FORMAT_BIG5 :
{
int encoding = -1;
switch (id)
{
case IDM_FORMAT_BIG5:
encoding = CP_BIG5;
encoding = NPP_CP_BIG5;
break;
case IDM_FORMAT_EUC_KR:
encoding = NPP_CP_EUC_KR;
break;
case IDM_FORMAT_SHIFT_JIS:
encoding = NPP_CP_SHIFT_JIS;
break;
case IDM_FORMAT_GB2312:
encoding = NPP_CP_GB2312;
break;
case IDM_FORMAT_TIS_620:
encoding = NPP_CP_TIS_620;
break;
case IDM_FORMAT_WIN1256:
encoding = NPP_CP_WIN_1256;
break;
case IDM_FORMAT_WIN1253:
encoding = NPP_CP_WIN_1253;
break;
case IDM_FORMAT_WIN1250:
encoding = NPP_CP_WIN_1250;
break;
default : // IDM_FORMAT_ANSI
@ -4685,13 +4712,13 @@ void Notepad_plus::command(int id)
_aboutDlg.doDialog();
if (isFirstTime && _nativeLangA)
{
if (_nativeLangEncoding == CP_BIG5)
if (_nativeLangEncoding == NPP_CP_BIG5)
{
char *authorName = "«J¤µ§^";
HWND hItem = ::GetDlgItem(_aboutDlg.getHSelf(), IDC_AUTHOR_NAME);
#ifdef UNICODE
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const wchar_t *authorNameW = wmc->char2wchar(authorName, CP_BIG5);
const wchar_t *authorNameW = wmc->char2wchar(authorName, NPP_CP_BIG5);
::SetWindowText(hItem, authorNameW);
#else
::SetWindowText(hItem, authorName);

View File

@ -398,7 +398,14 @@ BEGIN
MENUITEM "Encode in UCS-2 Little Endian", IDM_FORMAT_UCS_2LE
POPUP "More..."
BEGIN
MENUITEM "Chinese Traditional (Big5)", IDM_FORMAT_BIG5
MENUITEM "Arabic(Windows)", IDM_FORMAT_WIN1256
MENUITEM "Central European(Windows)" IDM_FORMAT_WIN1250
MENUITEM "Chinese Traditional(Big5)", IDM_FORMAT_BIG5
MENUITEM "Chinese Simplified(GB2312)", IDM_FORMAT_GB2312
MENUITEM "Greek(Windows)", IDM_FORMAT_WIN1253
MENUITEM "Japanese(Shift-JIS)", IDM_FORMAT_SHIFT_JIS
MENUITEM "Korean(EUC)", IDM_FORMAT_EUC_KR
MENUITEM "Thai(Windows)", IDM_FORMAT_TIS_620
END
MENUITEM SEPARATOR
MENUITEM "Convert to ANSI", IDM_FORMAT_CONV2_ANSI

View File

@ -23,7 +23,7 @@ void LastRecentFileList::initMenu(HMENU hMenu, int idBase, int posBase) {
_hMenu = hMenu;
_idBase = idBase;
_posBase = posBase;
_nativeLangEncoding = CP_ANSI_LATIN_1;
_nativeLangEncoding = NPP_CP_WIN_1252;
for (int i = 0 ; i < sizeof(_idFreeArray) ; i++)
_idFreeArray[i] = true;

View File

@ -238,7 +238,21 @@
#define IDM_FORMAT_CONV2_UCS_2BE (IDM_FORMAT + 12)
#define IDM_FORMAT_CONV2_UCS_2LE (IDM_FORMAT + 13)
#define IDM_FORMAT_BIG5 (IDM_FORMAT + 20)
#define IDM_FORMAT_WIN1250 (IDM_FORMAT + 20)
#define IDM_FORMAT_WIN1251 (IDM_FORMAT + 21)
#define IDM_FORMAT_WIN1252 (IDM_FORMAT + 22)
#define IDM_FORMAT_WIN1253 (IDM_FORMAT + 23)
#define IDM_FORMAT_WIN1254 (IDM_FORMAT + 24)
#define IDM_FORMAT_WIN1255 (IDM_FORMAT + 25)
#define IDM_FORMAT_WIN1256 (IDM_FORMAT + 26)
#define IDM_FORMAT_WIN1257 (IDM_FORMAT + 27)
#define IDM_FORMAT_WIN1258 (IDM_FORMAT + 28)
#define IDM_FORMAT_BIG5 (IDM_FORMAT + 29)
#define IDM_FORMAT_GB2312 (IDM_FORMAT + 30)
#define IDM_FORMAT_SHIFT_JIS (IDM_FORMAT + 31)
#define IDM_FORMAT_EUC_KR (IDM_FORMAT + 32)
#define IDM_FORMAT_TIS_620 (IDM_FORMAT + 33)
#define IDM_LANG (IDM + 6000)
#define IDM_LANGSTYLE_CONFIG_DLG (IDM_LANG + 1)