Revision: 9343 https://osdn.net/projects/ttssh2/scm/svn/commits/9343 Author: zmatsuo Date: 2021-08-02 00:32:29 +0900 (Mon, 02 Aug 2021) Log Message: ----------- lng ファイル選択部分を Unicode化 Modified Paths: -------------- trunk/teraterm/ttpdlg/ttdlg.c -------------- next part -------------- Modified: trunk/teraterm/ttpdlg/ttdlg.c =================================================================== --- trunk/teraterm/ttpdlg/ttdlg.c 2021-08-01 15:32:15 UTC (rev 9342) +++ trunk/teraterm/ttpdlg/ttdlg.c 2021-08-01 15:32:29 UTC (rev 9343) @@ -2821,12 +2821,12 @@ } static const char *LangList[] = {"English","Japanese","Russian","Korean","UTF-8",NULL}; -static const char **LangUIList = NULL; -#define LANG_EXT ".lng" +static const wchar_t **LangUIList = NULL; +#define LANG_EXT L".lng" -static const char *get_lang_folder() +static const wchar_t *get_lang_folder() { - return (IsWindowsNTKernel()) ? "lang_utf16le" : "lang"; + return (IsWindowsNTKernel()) ? L"lang_utf16le" : L"lang"; } // \x83\x81\x83\x82\x83\x8A\x83t\x83\x8A\x81[ @@ -2833,7 +2833,7 @@ static void free_lang_ui_list() { if (LangUIList) { - const char **p = LangUIList; + const wchar_t **p = LangUIList; while (*p) { free((void *)*p); p++; @@ -2843,57 +2843,58 @@ } } -static int make_sel_lang_ui(char *HomeDir) +static int make_sel_lang_ui(const wchar_t *HomeDir) { int i; int file_num; - char fullpath[1024]; + wchar_t *fullpath; HANDLE hFind; - WIN32_FIND_DATA fd; + WIN32_FIND_DATAW fd; free_lang_ui_list(); - _snprintf_s(fullpath, sizeof(fullpath), _TRUNCATE, "%s\\%s\\*%s", HomeDir, get_lang_folder(), LANG_EXT); + aswprintf(&fullpath, L"%s\\%s\\*%s", HomeDir, get_lang_folder(), LANG_EXT); file_num = 0; - hFind = FindFirstFile(fullpath,&fd); + hFind = FindFirstFileW(fullpath, &fd); if (hFind != INVALID_HANDLE_VALUE) { do { if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { file_num++; } - } while(FindNextFile(hFind,&fd)); + } while(FindNextFileW(hFind, &fd)); FindClose(hFind); } file_num++; // NULL - LangUIList = calloc(file_num, sizeof(char *)); + LangUIList = calloc(file_num, sizeof(wchar_t *)); i = 0; - hFind = FindFirstFile(fullpath,&fd); + hFind = FindFirstFileW(fullpath, &fd); if (hFind != INVALID_HANDLE_VALUE) { do { if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - LangUIList[i++] = _strdup(fd.cFileName); + LangUIList[i++] = wcsdup(fd.cFileName); } - } while(FindNextFile(hFind,&fd) && i < file_num); + } while(FindNextFileW(hFind, &fd) && i < file_num); FindClose(hFind); } LangUIList[i] = NULL; + free(fullpath); return i; } -static int get_sel_lang_ui(const char **list, char *selstr) +static int get_sel_lang_ui(const wchar_t **list, const wchar_t *selstr) { size_t n = 0; - const char **p = list; + const wchar_t **p = list; if (selstr == NULL || selstr[0] == '\0') { n = 0; // English } else { while (*p) { - if (strstr(selstr, *p)) { + if (wcsstr(selstr, *p)) { n = p - list; break; } @@ -2953,10 +2954,17 @@ } // \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 - uilist_count = make_sel_lang_ui(ts->HomeDir); - langui_sel = get_sel_lang_ui(LangUIList, ts->UILanguageFile_ini); - SetDropDownList(Dialog, IDC_GENLANG_UI, LangUIList, langui_sel); - if (LangUIList[0] == NULL) { + uilist_count = make_sel_lang_ui(ts->HomeDirW); + langui_sel = get_sel_lang_ui(LangUIList, ts->UILanguageFileW_ini); + if (LangUIList[0] != NULL) { + int i = 0; + while (LangUIList[i] != 0) { + SendDlgItemMessageW(Dialog, IDC_GENLANG_UI, CB_ADDSTRING, 0, (LPARAM)LangUIList[i]); + i++; + } + SendDlgItemMessage(Dialog, IDC_GENLANG_UI, CB_SETCURSEL, langui_sel - 1, 0); + } + else { EnableWindow(GetDlgItem(Dialog, IDC_GENLANG_UI), FALSE); } @@ -2997,7 +3005,7 @@ // \x8C\xBE\x8C\xEA\x83t\x83@\x83C\x83\x8B\x82\xAA\x95ύX\x82\xB3\x82\xEA\x82Ă\xA2\x82\xBD\x8Fꍇ w = (WORD)GetCurSel(Dialog, IDC_GENLANG_UI); if (1 <= w && w <= uilist_count && w != langui_sel) { - aswprintf(&ts->UILanguageFileW_ini, L"%hs\\%hs", get_lang_folder(), LangUIList[w - 1]); + aswprintf(&ts->UILanguageFileW_ini, L"%s\\%s", get_lang_folder(), LangUIList[w - 1]); WideCharToACP_t(ts->UILanguageFileW_ini, ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini)); ts->UILanguageFileW = GetUILanguageFileFullW(ts->HomeDirW, ts->UILanguageFileW_ini);