Revision: 9499 https://osdn.net/projects/ttssh2/scm/svn/commits/9499 Author: zmatsuo Date: 2021-10-24 01:09:57 +0900 (Sun, 24 Oct 2021) Log Message: ----------- Languate=Chinese時クラッシュすることがあったので修正 - Languate=Chinese時のiniファイルへの書き込み/読み込みができていなかったので修正 - 文字コードに関する部分を分離 - ttlib_charset.cpp,h, tttypes_charset.h を追加 Modified Paths: -------------- trunk/installer/release/TERATERM.INI trunk/teraterm/common/CMakeLists.txt trunk/teraterm/common/common_static.v16.vcxproj trunk/teraterm/common/common_static.v8.vcproj trunk/teraterm/common/ttlib.c trunk/teraterm/common/tttypes.h trunk/teraterm/teraterm/coding_pp.cpp trunk/teraterm/teraterm/vtterm.c trunk/teraterm/ttpcmn/ttcmn.c trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters trunk/teraterm/ttpdlg/ttdlg.c trunk/teraterm/ttpset/ttset.c Added Paths: ----------- trunk/teraterm/common/ttlib_charset.cpp trunk/teraterm/common/ttlib_charset.h trunk/teraterm/common/tttypes_charset.h -------------- next part -------------- Modified: trunk/installer/release/TERATERM.INI =================================================================== --- trunk/installer/release/TERATERM.INI 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/installer/release/TERATERM.INI 2021-10-23 16:09:57 UTC (rev 9499) @@ -30,7 +30,7 @@ ; Tera Term version number Version=2.3 -; Language (English/Japanese/Russian/Korean/UTF-8) +; Language (English/Japanese/Russian/Korean/Chinese/UTF-8) Language= ; User interface language file that includes message strings. Modified: trunk/teraterm/common/CMakeLists.txt =================================================================== --- trunk/teraterm/common/CMakeLists.txt 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/common/CMakeLists.txt 2021-10-23 16:09:57 UTC (rev 9499) @@ -38,6 +38,8 @@ ttlib.h ttlib_static.c ttlib_static_cpp.cpp + ttlib_charset.h + ttlib_charset.cpp win32helper.cpp win32helper.h ) Modified: trunk/teraterm/common/common_static.v16.vcxproj =================================================================== --- trunk/teraterm/common/common_static.v16.vcxproj 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/common/common_static.v16.vcxproj 2021-10-23 16:09:57 UTC (rev 9499) @@ -148,6 +148,7 @@ <ClCompile Include="getcontent.cpp" /> <ClCompile Include="i18n_static.c" /> <ClCompile Include="ttknownfolders.c" /> + <ClCompile Include="ttlib_charset.cpp" /> <ClCompile Include="ttlib_static.c" /> <ClCompile Include="ttlib_static_cpp.cpp" /> <ClCompile Include="win32helper.cpp" /> @@ -167,6 +168,7 @@ <ClInclude Include="getcontent.h" /> <ClInclude Include="ttknownfolders.h" /> <ClInclude Include="ttlib.h" /> + <ClInclude Include="ttlib_charset.h" /> <ClInclude Include="win32helper.h" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> Modified: trunk/teraterm/common/common_static.v8.vcproj =================================================================== --- trunk/teraterm/common/common_static.v8.vcproj 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/common/common_static.v8.vcproj 2021-10-23 16:09:57 UTC (rev 9499) @@ -293,6 +293,14 @@ > </File> <File + RelativePath=".\ttlib_charset.cpp" + > + </File> + <File + RelativePath=".\ttlib_charset.h" + > + </File> + <File RelativePath=".\ttlib_static.c" > </File> Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/common/ttlib.c 2021-10-23 16:09:57 UTC (rev 9499) @@ -1060,33 +1060,6 @@ return CDSIZEOF_STRUCT(OPENFILENAMEW,lpTemplateName); } -/** - * KanjiCodeTranslate(Language(dest), KanjiCodeID(source)) returns KanjiCodeID - * @param[in] lang (IdEnglish, IdJapanese, IdRussian, ...) - * @param[in] kcode (IdSJIS, IdEUC, ... IdKOI8 ... ) - * @return lang\x82ɑ\xB6\x8D݂\xB7\x82銿\x8E\x9A\x83R\x81[\x83h\x82\xF0\x95Ԃ\xB7 - * - * lang\x82ɑ\xB6\x8D݂\xB5\x82Ȃ\xA2\x8A\xBF\x8E\x9A\x83R\x81[\x83h\x82\xF0\x8Eg\x97p\x82\xB5\x82Ȃ\xA2\x82悤\x82\xB1\x82̊\x94\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9 - * - ini\x83t\x83@\x83C\x83\x8B\x82̓ǂݍ\x9E\x82ݎ\x9E - * - \x90ݒ\xE8\x82\xC5lang\x82\xF0\x90\xE8\x91ւ\xA6\x82\xBD\x8E\x9E - */ -int KanjiCodeTranslate(int lang, int kcode) -{ - static const int Table[][5] = { - {1, 2, 3, 4, 5}, /* to English (dummy) */ - {1, 2, 3, 4, 5}, /* to Japanese(dummy) */ - {1, 2, 3, 4, 5}, /* to Russian (dummy) */ - {1, 1, 1, 4, 5}, /* to Korean */ - {4, 4, 4, 4, 5}, /* to Utf8 */ - {1, 2, 2, 2, 2}, /* to Chinese */ - }; - if (lang < 1 || lang > IdLangMax) lang = 1; - if (kcode < 1 || kcode > 5) kcode = 1; - lang--; - kcode--; - return Table[lang][kcode]; -} - char *mctimelocal(char *format, BOOL utc_flag) { SYSTEMTIME systime; Added: trunk/teraterm/common/ttlib_charset.cpp =================================================================== --- trunk/teraterm/common/ttlib_charset.cpp (rev 0) +++ trunk/teraterm/common/ttlib_charset.cpp 2021-10-23 16:09:57 UTC (rev 9499) @@ -0,0 +1,165 @@ +/* + * Copyright (C) 1994-1998 T. Teranishi + * (C) 2021- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "tttypes_charset.h" + +#include "ttlib_charset.h" + +static const TLanguageList LanguageList[] = { + { IdUtf8, "UTF-8" }, + { IdJapanese, "Japanese" }, + { IdRussian, "Russian" }, + { IdEnglish, "English" }, + { IdKorean, "Korean" }, + { IdChinese, "Chinese" }, +}; + +static const TKanjiList KanjiList[] = { + { IdUtf8, IdUTF8, "UTF-8", "UTF-8" }, + { IdEnglish, IdCodeEnglish, "English", "English" }, + { IdJapanese, IdSJIS, "Japanese/SJIS (CP932)", "SJIS" }, + { IdJapanese, IdEUC, "Japanese/EUC", "EUC" }, + { IdJapanese, IdJIS, "Japanese/JIS", "JIS" }, + { IdJapanese, IdUTF8, "Japanese/UTF-8", "UTF-8" }, + { IdRussian, IdWindows, "Russian/Windows (CP1251)", "CP1251" }, + { IdRussian, IdKOI8, "Russian/KOI8-R", "KOI8-R" }, + { IdRussian, Id866, "Russian/CP 866", "CP866" }, + { IdRussian, IdISO, "Russian/ISO 8859-5", "IS8859-5" }, + { IdKorean, IdKoreanCP51949, "Korean/KS5601 (CP51949)", "KS5601" }, + { IdKorean, IdUTF8, "Korean/UTF-8", "UTF-8" }, + { IdChinese, IdCnGB2312, "China/GB2312 (CP936)", "GB2312" }, + { IdChinese, IdCnBig5, "China/Big5 (CP950)", "BIG5" }, + { IdChinese, IdUTF8, "China/UTF-8", "UTF-8" }, +}; + +const TLanguageList *GetLanguageList(int index) +{ + if (index < 0 || index >= _countof(LanguageList)) { + return NULL; + } + return &LanguageList[index]; +} + +const char *GetLanguageStr(int language) +{ + for(int i = 0; i < _countof(LanguageList); i++) { + if (LanguageList[i].language == language) { + return LanguageList[i].str; + } + } + return LanguageList[0].str; +} + +int GetLanguageFromStr(const char *language_str) +{ + for(int i = 0; i < _countof(LanguageList); i++) { + if (strcmp(language_str, LanguageList[i].str) == 0) { + return LanguageList[i].language; + } + } + return LanguageList[0].language; +} + + +/** + * \x8D\\x91\xA2\x91̂\xCC1\x97v\x91f\x82\xF0\x8E擾 + * \x94͈͊O\x82ɂȂ\xC1\x82\xBD\x82\xE7NULL\x82\xAA\x95Ԃ\xE9 + */ +const TKanjiList *GetKanjiList(int index) +{ + if (index < 0 || index >= _countof(KanjiList)) { + return NULL; + } + return &KanjiList[index]; +} + +/** + * \x8A\xBF\x8E\x9A\x83R\x81[\x83h\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8E擾 + * @param[in] language (=ts.Language) + * IdJapanese, IdKorean, ... + * @param[in] kanji_code (=ts.KanjiCode (receive) or ts.KanjiCodeSend) + * IdEUC, IdJIS, IdUTF8, ... + * @return \x8A\xBF\x8E\x9A\x83R\x81[\x83h\x95\xB6\x8E\x9A\x97\xF1 + */ +const char *GetKanjiCodeStr(int language, int kanji_code) +{ + for (int i = 0; i < sizeof(KanjiList); i++) { + if (KanjiList[i].lang == language && + KanjiList[i].coding == kanji_code) { + return KanjiList[i].KanjiCode; + } + } + return "UTF-8"; +} + +/** + * \x8A\xBF\x8E\x9A\x83R\x81[\x83h\x82\xF0\x8E擾 + * @param[in] language (=ts.Language) + * IdJapanese, IdKorean, ... + * @param[in] kanji_code_str + * \x8A\xBF\x8E\x9A\x83R\x81[\x83h\x95\xB6\x8E\x9A\x97\xF1 + * @return \x8A\xBF\x8E\x9A\x83R\x81[\x83h + */ +int GetKanjiCodeFromStr(int language, const char *kanji_code_str) +{ + for (int i = 0; i < sizeof(KanjiList); i++) { + if (KanjiList[i].lang == language && + strcmp(KanjiList[i].KanjiCode, kanji_code_str) == 0) { + return KanjiList[i].coding; + } + } + return IdUTF8; +} + +/** + * KanjiCodeTranslate(Language(dest), KanjiCodeID(source)) returns KanjiCodeID + * @param[in] lang (IdEnglish, IdJapanese, IdRussian, ...) + * @param[in] kcode (IdSJIS, IdEUC, ... IdKOI8 ... ) + * @return lang\x82ɑ\xB6\x8D݂\xB7\x82銿\x8E\x9A\x83R\x81[\x83h\x82\xF0\x95Ԃ\xB7 + * + * lang\x82ɑ\xB6\x8D݂\xB5\x82Ȃ\xA2\x8A\xBF\x8E\x9A\x83R\x81[\x83h\x82\xF0\x8Eg\x97p\x82\xB5\x82Ȃ\xA2\x82悤\x82\xB1\x82̊\x94\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9 + * - ini\x83t\x83@\x83C\x83\x8B\x82̓ǂݍ\x9E\x82ݎ\x9E + * - \x90ݒ\xE8\x82\xC5lang\x82\xF0\x90\xE8\x91ւ\xA6\x82\xBD\x8E\x9E + */ +int KanjiCodeTranslate(int lang, int kcode) +{ + static const int Table[][5] = { + {1, 2, 3, 4, 5}, /* to English (dummy) */ + {1, 2, 3, 4, 5}, /* to Japanese(dummy) */ + {1, 2, 3, 4, 5}, /* to Russian (dummy) */ + {1, 1, 1, 4, 5}, /* to Korean */ + {4, 4, 4, 4, 5}, /* to Utf8 */ + {1, 2, 2, 2, 2}, /* to Chinese */ + }; + if (lang < 1 || lang > IdLangMax) lang = 1; + if (kcode < 1 || kcode > 5) kcode = 1; + lang--; + kcode--; + return Table[lang][kcode]; +} Added: trunk/teraterm/common/ttlib_charset.h =================================================================== --- trunk/teraterm/common/ttlib_charset.h (rev 0) +++ trunk/teraterm/common/ttlib_charset.h 2021-10-23 16:09:57 UTC (rev 9499) @@ -0,0 +1,32 @@ + +#pragma once + +#include "tttypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int language; + const char *str; +} TLanguageList; + +typedef struct { + int lang; + int coding; + const char *CodeName; + const char *KanjiCode; +} TKanjiList; + +const TLanguageList *GetLanguageList(int index); +const char *GetLanguageStr(int language); +int GetLanguageFromStr(const char *language_str); + +const TKanjiList *GetKanjiList(int index); +const char *GetKanjiCodeStr(int language, int kanji_code); +int GetKanjiCodeFromStr(int language, const char *kanji_code_str); + +#ifdef __cplusplus +} +#endif Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/common/tttypes.h 2021-10-23 16:09:57 UTC (rev 9499) @@ -33,6 +33,7 @@ #include "teraterm.h" #include "tt-version.h" #include "../teraterm/unicode_test.h" +#include "tttypes_charset.h" #define IdBreakTimer 1 #define IdDelayTimer 2 @@ -152,15 +153,6 @@ #define KmtOptFileAttr 2 #define KmtOptSlideWin 4 - /* Language */ -#define IdEnglish 1 -#define IdJapanese 2 -#define IdRussian 3 -#define IdKorean 4 //HKS -#define IdUtf8 5 -#define IdChinese 6 -#define IdLangMax IdChinese - // LogDialog Option #define LOGDLG_BINARY 1 @@ -678,43 +670,6 @@ #define IdVT520 11 #define IdVT525 12 - /* Kanji Code ID */ - /* ts.KanjiCode, ts.KanjiCodeSend \x82̒l */ - -// ts.Language == IdEnglish -#define IdCodeEnglish 1 - -// ts.Language == IdJapanese -#define IdSJIS 1 -#define IdEUC 2 -#define IdJIS 3 -#define IdUTF8 4 // IdUtf8 (\x8F\xAC\x95\xB6\x8E\x9A)\x82\xCD ts.Language \x97p -#define IdUTF8m 5 - -// ts.Language == IdRussian -// Russian code sets -#define IdWindows 1 -#define IdKOI8 2 -#define Id866 3 -#define IdISO 4 - -// ts.Language == IdKorean -// Korean -#define IdKoreanCP51949 1 // CP51949, KS5601 - -// ts.Language == IdChinese -// China -#define IdCnGB2312 1 // 1 CP936, GB2312 -#define IdCnBig5 2 // 2 CP950, Big5 - - /* KanjiIn modes */ -#define IdKanjiInA 1 -#define IdKanjiInB 2 - /* KanjiOut modes */ -#define IdKanjiOutB 1 -#define IdKanjiOutJ 2 -#define IdKanjiOutH 3 - #define TermWidthMax 1000 #define TermHeightMax 500 Added: trunk/teraterm/common/tttypes_charset.h =================================================================== --- trunk/teraterm/common/tttypes_charset.h (rev 0) +++ trunk/teraterm/common/tttypes_charset.h 2021-10-23 16:09:57 UTC (rev 9499) @@ -0,0 +1,76 @@ +/* + * Copyright (C) 1994-1998 T. Teranishi + * (C) 2021- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +/* Language */ +#define IdEnglish 1 +#define IdJapanese 2 +#define IdRussian 3 +#define IdKorean 4 //HKS +#define IdUtf8 5 +#define IdChinese 6 +#define IdLangMax IdChinese + + /* Kanji Code ID */ + /* ts.KanjiCode, ts.KanjiCodeSend \x82̒l */ + +// ts.Language == IdEnglish +#define IdCodeEnglish 1 + +// ts.Language == IdJapanese +#define IdSJIS 1 +#define IdEUC 2 +#define IdJIS 3 +#define IdUTF8 4 // IdUtf8 (\x8F\xAC\x95\xB6\x8E\x9A)\x82\xCD ts.Language \x97p +#define IdUTF8m 5 + +// ts.Language == IdRussian +// Russian code sets +#define IdWindows 1 +#define IdKOI8 2 +#define Id866 3 +#define IdISO 4 + +// ts.Language == IdKorean +// Korean +#define IdKoreanCP51949 1 // CP51949, KS5601 + +// ts.Language == IdChinese +// China +#define IdCnGB2312 1 // 1 CP936, GB2312 +#define IdCnBig5 2 // 2 CP950, Big5 + + /* KanjiIn modes */ +#define IdKanjiInA 1 +#define IdKanjiInB 2 + /* KanjiOut modes */ +#define IdKanjiOutB 1 +#define IdKanjiOutJ 2 +#define IdKanjiOutH 3 Modified: trunk/teraterm/teraterm/coding_pp.cpp =================================================================== --- trunk/teraterm/teraterm/coding_pp.cpp 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/teraterm/coding_pp.cpp 2021-10-23 16:09:57 UTC (rev 9499) @@ -40,6 +40,7 @@ #include "compat_win.h" #include "setting.h" #include "helpid.h" +#include "ttlib_charset.h" #include "coding_pp.h" @@ -51,28 +52,6 @@ static const char *KanjiOutList2[] = {"^[(B","^[(J","^[(H",NULL}; static const char *CellWidthList[] = { "1 Cell", "2 Cell", NULL }; -static const struct { - int lang; - int coding; - const char *CodeName; -} KanjiList[] = { - { IdUtf8, IdUTF8, "UTF-8" }, - { IdEnglish, IdCodeEnglish, "English" }, - { IdJapanese, IdSJIS, "Japanese/SJIS (CP932)" }, - { IdJapanese, IdEUC, "Japanese/EUC" }, - { IdJapanese, IdJIS, "Japanese/JIS" }, - { IdJapanese, IdUTF8, "Japanese/UTF-8" }, - { IdRussian, IdWindows, "Russian/Windows (CP1251)" }, - { IdRussian, IdKOI8, "Russian/KOI8-R" }, - { IdRussian, Id866, "Russian/CP 866" }, - { IdRussian, IdISO, "Russian/ISO 8859-5" }, - { IdKorean, IdKoreanCP51949, "Korean/KS5601 (CP51949)" }, - { IdKorean, IdUTF8, "Korean/UTF-8" }, - { IdChinese, IdCnGB2312, "China/GB2312 (CP936)" }, - { IdChinese, IdCnBig5, "China/Big5 (CP950)" }, - { IdChinese, IdUTF8, "China/UTF-8" }, -}; - struct CodingPPData { TTTSet *pts; const char *UILanguageFile; @@ -104,19 +83,23 @@ int recv_index = 0; int send_index = 0; - for (int i = 0; i < _countof(KanjiList); i++) { - int id = KanjiList[i].lang * 100 + KanjiList[i].coding; + for (int i = 0;; i++) { + const TKanjiList *p = GetKanjiList(i); + if (p == NULL) { + break; + } + int id = p->lang * 100 + p->coding; int index = - (int)SendDlgItemMessageA(hWnd, IDC_TERMKANJI, CB_ADDSTRING, 0, (LPARAM)KanjiList[i].CodeName); + (int)SendDlgItemMessageA(hWnd, IDC_TERMKANJI, CB_ADDSTRING, 0, (LPARAM)p->CodeName); SendDlgItemMessageA(hWnd, IDC_TERMKANJI, CB_SETITEMDATA, index, id); - if (ts->Language == KanjiList[i].lang && ts->KanjiCode == KanjiList[i].coding) { + if (ts->Language == p->lang && ts->KanjiCode == p->coding) { recv_index = i; } index = - (int)SendDlgItemMessageA(hWnd, IDC_TERMKANJISEND, CB_ADDSTRING, 0, (LPARAM)KanjiList[i].CodeName); + (int)SendDlgItemMessageA(hWnd, IDC_TERMKANJISEND, CB_ADDSTRING, 0, (LPARAM)p->CodeName); SendDlgItemMessageA(hWnd, IDC_TERMKANJISEND, CB_SETITEMDATA, index, id); - if (ts->Language == KanjiList[i].lang && ts->KanjiCodeSend == KanjiList[i].coding) { + if (ts->Language == p->lang && ts->KanjiCodeSend == p->coding) { send_index = i; } } Modified: trunk/teraterm/teraterm/vtterm.c =================================================================== --- trunk/teraterm/teraterm/vtterm.c 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/teraterm/vtterm.c 2021-10-23 16:09:57 UTC (rev 9499) @@ -6334,14 +6334,30 @@ break; case IdRussian: - if (ParseFirstRus(b)) { - return; + switch (ts.KanjiCode) { + case IdUTF8: + if (ParseFirstUTF8(b, 0)) { + return; + } + break; + default: + if (ParseFirstRus(b)) { + return; + } } break; case IdChinese: - if (ParseFirstCn(b)) { - return; + switch (ts.KanjiCode) { + case IdUTF8: + if (ParseFirstUTF8(b, 0)) { + return; + } + break; + default: + if (ParseFirstCn(b)) { + return; + } } break; } Modified: trunk/teraterm/ttpcmn/ttcmn.c =================================================================== --- trunk/teraterm/ttpcmn/ttcmn.c 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/ttpcmn/ttcmn.c 2021-10-23 16:09:57 UTC (rev 9499) @@ -1117,7 +1117,8 @@ output_char_count = 1; } else if (cv->Language == IdUtf8 || (cv->Language == IdJapanese && states->KanjiCode == IdUTF8) || - (cv->Language == IdKorean && states->KanjiCode == IdUTF8)) + (cv->Language == IdKorean && states->KanjiCode == IdUTF8) || + (cv->Language == IdChinese && states->KanjiCode == IdUTF8)) { // UTF-8 \x82ŏo\x97\xCD size_t utf8_len = sizeof(TempStr); Modified: trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj 2021-10-23 16:09:57 UTC (rev 9499) @@ -141,11 +141,11 @@ </ItemGroup> <ItemGroup> <ClInclude Include="..\common\compat_win.h" /> + <ClInclude Include="..\common\devpkey_teraterm.h" /> <ClInclude Include="..\common\dllutil.h" /> <ClInclude Include="..\common\i18n.h" /> <ClInclude Include="..\common\servicenames.h" /> <ClInclude Include="..\common\ttlib.h" /> - <ClInclude Include="devpkey_teraterm.h" /> <ClInclude Include="language.h" /> </ItemGroup> <ItemGroup> Modified: trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters 2021-10-23 16:09:57 UTC (rev 9499) @@ -54,9 +54,6 @@ <ClInclude Include="..\common\ttlib.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="devpkey_teraterm.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="..\common\compat_win.h"> <Filter>Header Files</Filter> </ClInclude> @@ -63,6 +60,9 @@ <ClInclude Include="..\common\dllutil.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\common\devpkey_teraterm.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="ttpcmn.def"> Modified: trunk/teraterm/ttpdlg/ttdlg.c =================================================================== --- trunk/teraterm/ttpdlg/ttdlg.c 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/ttpdlg/ttdlg.c 2021-10-23 16:09:57 UTC (rev 9499) @@ -56,6 +56,7 @@ #include "asprintf.h" #include "win32helper.h" #include "compat_win.h" +#include "ttlib_charset.h" // Oniguruma: Regular expression library #define ONIG_EXTERN extern @@ -106,7 +107,6 @@ static const char *KanjiInList[] = {"^[$@","^[$B",NULL}; static const char *KanjiOutList[] = {"^[(B","^[(J",NULL}; static const char *KanjiOutList2[] = {"^[(B","^[(J","^[(H",NULL}; -static const char *RussList[] = {"Windows(CP 1251)","KOI8-R","CP 866","ISO 8859-5",NULL}; static const char *RussList2[] = {"Windows","KOI8-R",NULL}; static const char *MetaList[] = {"off", "on", "left", "right", NULL}; static const char *MetaList2[] = {"off", "on", NULL}; @@ -2816,7 +2816,6 @@ return FALSE; } -static const char *LangList[] = {"English","Japanese","Russian","Korean","UTF-8",NULL}; static const wchar_t **LangUIList = NULL; #define LANG_EXT L".lng" @@ -2945,8 +2944,20 @@ SendDlgItemMessage(Dialog, IDC_GENPORT, CB_SETCURSEL,w,0); if ((ts->MenuFlag & MF_NOLANGUAGE)==0) { + int sel = 0; + int i; ShowDlgItem(Dialog,IDC_GENLANGLABEL,IDC_GENLANG); - SetDropDownList(Dialog, IDC_GENLANG, LangList, ts->Language); + for (i = 0;; i++) { + const TLanguageList *lang = GetLanguageList(i); + if (lang == NULL) { + break; + } + if (ts->Language == lang->language) { + sel = i; + } + SendDlgItemMessageA(Dialog, IDC_GENLANG, CB_ADDSTRING, 0, (LPARAM)lang->str); + } + SendDlgItemMessage(Dialog, IDC_GENLANG, CB_SETCURSEL, sel, 0); } // \x8Dŏ\x89\x82Ɏw\x92肳\x82\xEA\x82Ă\xA2\x82錾\x8C\xEA\x83t\x83@\x83C\x83\x8B\x82̔ԍ\x86\x82\xF0\x8Ao\x82\xA6\x82Ă\xA8\x82\xAD\x81B Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2021-10-23 16:09:46 UTC (rev 9498) +++ trunk/teraterm/ttpset/ttset.c 2021-10-23 16:09:57 UTC (rev 9499) @@ -48,6 +48,7 @@ #include "codeconv.h" #include "win32helper.h" #include "inifile_com.h" +#include "ttlib_charset.h" #define DllExport __declspec(dllexport) #include "ttset.h" @@ -65,8 +66,6 @@ { "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282", "VT320", "VT382", "VT420", "VT520", "VT525", NULL }; -static PCHAR far RussList[] = - { "Windows", "KOI8-R", "CP-866", "ISO-8859-5", NULL }; static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL }; @@ -770,16 +769,9 @@ /* Language */ GetPrivateProfileString(Section, "Language", "", Temp, sizeof(Temp), FName); - if (_stricmp(Temp, "Japanese") == 0) - ts->Language = IdJapanese; - else if (_stricmp(Temp, "Russian") == 0) - ts->Language = IdRussian; - else if (_stricmp(Temp, "English") == 0) - ts->Language = IdEnglish; - else if (_stricmp(Temp,"Korean") == 0) // HKS - ts->Language = IdKorean; - else if (_stricmp(Temp,"UTF-8") == 0) - ts->Language = IdUtf8; + if (Temp[0] != 0) { + ts->Language = GetLanguageFromStr(Temp); + } else { switch (PRIMARYLANGID(GetSystemDefaultLangID())) { case LANG_JAPANESE: @@ -880,23 +872,7 @@ /* Kanji Code (receive) */ GetPrivateProfileString(Section, "KanjiReceive", "", Temp, sizeof(Temp), FName); - if (_stricmp(Temp, "EUC") == 0) - ts->KanjiCode = IdEUC; - else if (_stricmp(Temp, "JIS") == 0) - ts->KanjiCode = IdJIS; - else if (_stricmp(Temp, "UTF-8") == 0) - ts->KanjiCode = IdUTF8; - else if (_stricmp(Temp, "UTF-8m") == 0) - ts->KanjiCode = IdUTF8m; - else if (_stricmp(Temp, "KS5601") == 0) - ts->KanjiCode = IdSJIS; - else - ts->KanjiCode = IdSJIS; - // KanjiCode/KanjiCodeSend \x82\xF0\x8C\xBB\x8D݂\xCC Language \x82ɑ\xB6\x8D݂\xB7\x82\xE9\x92l\x82ɒu\x82\xAB\x8A\xB7\x82\xA6\x82\xE9 - { - WORD KanjiCode = ts->KanjiCode; - ts->KanjiCode = KanjiCodeTranslate(ts->Language,KanjiCode); - } + ts->KanjiCode = GetKanjiCodeFromStr(ts->Language, Temp); /* Katakana (receive) */ GetPrivateProfileString(Section, "KatakanaReceive", "", @@ -909,21 +885,7 @@ /* Kanji Code (transmit) */ GetPrivateProfileString(Section, "KanjiSend", "", Temp, sizeof(Temp), FName); - if (_stricmp(Temp, "EUC") == 0) - ts->KanjiCodeSend = IdEUC; - else if (_stricmp(Temp, "JIS") == 0) - ts->KanjiCodeSend = IdJIS; - else if (_stricmp(Temp, "UTF-8") == 0) - ts->KanjiCodeSend = IdUTF8; - else if (_stricmp(Temp, "KS5601") == 0) - ts->KanjiCode = IdSJIS; - else - ts->KanjiCodeSend = IdSJIS; - // KanjiCode/KanjiCodeSend \x82\xF0\x8C\xBB\x8D݂\xCC Language \x82ɑ\xB6\x8D݂\xB7\x82\xE9\x92l\x82ɒu\x82\xAB\x8A\xB7\x82\xA6\x82\xE9 - { - WORD KanjiCodeSend = ts->KanjiCodeSend; - ts->KanjiCodeSend = KanjiCodeTranslate(ts->Language,KanjiCodeSend); - } + ts->KanjiCodeSend = GetKanjiCodeFromStr(ts->Language, Temp); /* Katakana (receive) */ GetPrivateProfileString(Section, "KatakanaSend", "", @@ -2276,25 +2238,11 @@ } /* Language */ - switch (ts->Language) { - case IdJapanese: - strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE); - break; - case IdKorean: - strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE); - break; - case IdRussian: - strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE); - break; - case IdUtf8: - strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE); - break; - default: - strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE); + { + const char *language_str = GetLanguageStr(ts->Language); + WritePrivateProfileString(Section, "Language", language_str, FName); } - WritePrivateProfileString(Section, "Language", Temp, FName); - /* Port type */ WritePrivateProfileString(Section, "Port", (ts->PortType==IdSerial)?"serial":"tcpip", FName); @@ -2352,32 +2300,10 @@ } /* Kanji Code (receive) */ - switch (ts->KanjiCode) { - case IdEUC: - strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE); - break; - case IdJIS: - strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE); - break; - case IdUTF8: - strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE); - break; - case IdUTF8m: - strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE); - break; - default: - switch (ts->Language) { - case IdJapanese: - strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE); - break; - case IdKorean: - strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE); - break; - default: - strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE); - } + { + const char *code_str = GetKanjiCodeStr(ts->Language, ts->KanjiCode); + WritePrivateProfileString(Section, "KanjiReceive", code_str, FName); } - WritePrivateProfileString(Section, "KanjiReceive", Temp, FName); /* Katakana (receive) */ if (ts->JIS7Katakana == 1) @@ -2388,29 +2314,10 @@ WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName); /* Kanji Code (transmit) */ - switch (ts->KanjiCodeSend) { - case IdEUC: - strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE); - break; - case IdJIS: - strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE); - break; - case IdUTF8: - strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE); - break; - default: - switch (ts->Language) { - case IdJapanese: - strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE); - break; - case IdKorean: - strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE); - break; - default: - strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE); - } + { + const char *code_str = GetKanjiCodeStr(ts->Language, ts->KanjiCodeSend); + WritePrivateProfileString(Section, "KanjiSend", code_str, FName); } - WritePrivateProfileString(Section, "KanjiSend", Temp, FName); /* Katakana (transmit) */ if (ts->JIS7KatakanaSend == 1) @@ -3811,8 +3718,7 @@ void PASCAL ParseParam(wchar_t *Param, PTTSet ts, PCHAR DDETopic) { - int i, pos, c; - //int param_top; + int pos, c; wchar_t Temp[MaxStrLen]; // ttpmacro\x82\xA9\x82\xE7\x8CĂ\xEA\x82邱\x82Ƃ\xF0\x91z\x92肵MaxStrLen\x83T\x83C\x83Y\x82Ƃ\xB7\x82\xE9 wchar_t Temp2[MaxStrLen]; WORD ParamPort = 0; @@ -3837,7 +3743,7 @@ /* Get command line parameters */ if (DDETopic != NULL) DDETopic[0] = 0; - i = 0; + /* the first term shuld be executable filename of Tera Term */ start = GetParam(Temp, _countof(Temp), Param);