• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7327 (tree)
Time2018-12-15 00:41:26
Authorzmatsuo

Log Message

ttproxy unicode化

Change Summary

Incremental Difference

--- branches/cmake/TTProxy/CMakeLists.txt (revision 7326)
+++ branches/cmake/TTProxy/CMakeLists.txt (revision 7327)
@@ -1,18 +1,33 @@
11 project(ttproxy)
22
3+if(USE_UNICODE_API)
4+ add_definitions(-DUNICODE -D_UNICODE)
5+endif()
6+
37 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
48
9+if(MSVC)
10+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
11+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
12+endif()
13+
514 include(${CMAKE_CURRENT_SOURCE_DIR}/../libs/lib_openssl.cmake)
615
716 set(COMMON_SRC
817 ../teraterm/common/ttlib.h
918 ../teraterm/common/i18n.h
19+ ../teraterm/common/ttplugin.h
20+ ../teraterm/common/tttypes.h
21+ ../teraterm/common/tt-version.h
22+ ../teraterm/common/codeconv.h
23+ ../teraterm/common/codeconv.cpp
24+ ../teraterm/common/dlglib.h
25+ ../teraterm/common/dlglib.c
26+ ../teraterm/common/dlglib_cpp.cpp
27+ ../teraterm/common/dlglib_tmpl.cpp
1028 ../teraterm/teraterm/ttdialog.h
1129 ../teraterm/teraterm/ttfileio.h
12- ../teraterm/common/ttplugin.h
1330 ../teraterm/teraterm/ttsetup.h
14- ../teraterm/common/tttypes.h
15- ../teraterm/common/tt-version.h
1631 ../teraterm/teraterm/ttwsk.h
1732 )
1833 source_group(
--- branches/cmake/TTProxy/Logger.h (revision 7326)
+++ branches/cmake/TTProxy/Logger.h (revision 7327)
@@ -70,7 +70,7 @@
7070 WriteFile(logfile, label, strlen(label), &written, NULL);
7171 WriteFile(logfile, ": [", 3, &written, NULL);
7272 while (size-- > 0) {
73- len = wsprintf(buf, " %02x", *data++);
73+ len = wsprintfA(buf, " %02x", *data++);
7474 WriteFile(logfile, buf, 3, &written, NULL);
7575 }
7676 WriteFile(logfile, " ]\r\n", 4, &written, NULL);
--- branches/cmake/TTProxy/ProxyWSockHook.h (revision 7326)
+++ branches/cmake/TTProxy/ProxyWSockHook.h (revision 7327)
@@ -17,16 +17,23 @@
1717
1818 #include "ttlib.h"
1919 #include "i18n.h"
20+#include "codeconv.h"
21+#include "dlglib.h"
2022
2123 extern char UILanguageFile[MAX_PATH];
2224
23-void UTIL_get_lang_msg(const char *key, PCHAR buf, int buf_len, const char *def)
25+void UTIL_get_lang_msg(const char *key, TCHAR *buf, int buf_len, const TCHAR *def)
2426 {
25- GetI18nStr("TTProxy", key, buf, buf_len, def, UILanguageFile);
27+ GetI18nStrT("TTProxy", key, buf, buf_len, def, UILanguageFile);
2628 }
2729
28-int UTIL_get_lang_font(const char *key, HWND dlg, PLOGFONT logfont, HFONT *font)
30+void UTIL_get_lang_msgU8(const char *key, char *buf, int buf_len, const char *def)
2931 {
32+ GetI18nStrU8("TTProxy", key, buf, buf_len, def, UILanguageFile);
33+}
34+
35+int UTIL_get_lang_font(const char *key, HWND dlg, PLOGFONTA logfont, HFONT *font)
36+{
3037 if (GetI18nLogfont("TTProxy", key, logfont,
3138 GetDeviceCaps(GetDC(dlg),LOGPIXELSY),
3239 UILanguageFile) == FALSE) {
@@ -33,7 +40,7 @@
3340 return FALSE;
3441 }
3542
36- if ((*font = CreateFontIndirect(logfont)) == NULL) {
43+ if ((*font = CreateFontIndirectA(logfont)) == NULL) {
3744 return FALSE;
3845 }
3946
@@ -44,7 +51,7 @@
4451 public:
4552 class MessageShower {
4653 public:
47- virtual void showMessage(const char* message)const = 0;
54+ virtual void showMessage(const TCHAR* message)const = 0;
4855 };
4956 private:
5057 struct DUMMYHOSTENT {
@@ -136,57 +143,57 @@
136143 private:
137144 struct PROXY_TYPE_TABLE {
138145 Type type;
139- const char* name;
146+ const TCHAR* name;
140147 };
141148 static const PROXY_TYPE_TABLE* proxy_type_table() {
142149 static PROXY_TYPE_TABLE table[] = {
143- {TYPE_HTTP, "http"},
144- {TYPE_SOCKS5, "socks"},
145- {TYPE_SOCKS4, "socks4"},
146- {TYPE_TELNET, "telnet"},
147- {TYPE_SOCKS5, "socks5"},
148- {TYPE_NONE_FORCE, "none"},
149- {TYPE_HTTP_SSL, "http+ssl"},
150- {TYPE_SOCKS5_SSL, "socks+ssl"},
151- {TYPE_SOCKS4_SSL, "socks4+ssl"},
152- {TYPE_TELNET_SSL, "telnet+ssl"},
153- {TYPE_SOCKS5_SSL, "socks5+ssl"},
154- {TYPE_SSL, "ssl"},
155- {TYPE_SSL, "none+ssl"},
150+ {TYPE_HTTP, _T("http")},
151+ {TYPE_SOCKS5, _T("socks")},
152+ {TYPE_SOCKS4, _T("socks4")},
153+ {TYPE_TELNET, _T("telnet")},
154+ {TYPE_SOCKS5, _T("socks5")},
155+ {TYPE_NONE_FORCE, _T("none")},
156+ {TYPE_HTTP_SSL, _T("http+ssl")},
157+ {TYPE_SOCKS5_SSL, _T("socks+ssl")},
158+ {TYPE_SOCKS4_SSL, _T("socks4+ssl")},
159+ {TYPE_TELNET_SSL, _T("telnet+ssl")},
160+ {TYPE_SOCKS5_SSL, _T("socks5+ssl")},
161+ {TYPE_SSL, _T("ssl")},
162+ {TYPE_SSL, _T("none+ssl")},
156163 {TYPE_NONE, NULL},
157164 };
158165 return table;
159166 }
160167 public:
161- static Type parseType(const char* string) {
162- return parseType(string, string + strlen(string));
168+ static Type parseType(const TCHAR* string) {
169+ return parseType(string, string + _tcslen(string));
163170 }
164- static Type parseType(const char* string, const char* end) {
171+ static Type parseType(const TCHAR* string, const TCHAR* end) {
165172 int length = end - string;
166- char* buffer = (char*) alloca(length + 1);
167- char* dst = buffer;
173+ TCHAR* buffer = (TCHAR*) alloca(sizeof(TCHAR) * (length + 1));
174+ TCHAR* dst = buffer;
168175 while (length-- > 0 && *string != '\0') {
169- int ch = *string++;
170- if ('A' <= ch && ch <= 'Z') {
171- ch += 'a' - 'A';
176+ TCHAR ch = *string++;
177+ if (_T('A') <= ch && ch <= _T('Z')) {
178+ ch += _T('a') - _T('A');
172179 }
173180 *dst++ = ch;
174181 }
175- *dst = '\0';
182+ *dst = _T('\0');
176183 const PROXY_TYPE_TABLE* table = proxy_type_table();
177184 bool ssl_enabled = SSLSocket::isEnabled();
178185 while (table->name != NULL) {
179- if (!ssl_enabled && strstr(table->name, "ssl") != NULL) {
186+ if (!ssl_enabled && _tcsstr(table->name, _T("ssl")) != NULL) {
180187 table++;
181188 continue;
182189 }
183- if (strcmp(buffer, table->name) == 0)
190+ if (_tcscmp(buffer, table->name) == 0)
184191 return table->type;
185192 table++;
186193 }
187194 return TYPE_NONE;
188195 }
189- static const char* getTypeName(Type type) {
196+ static const TCHAR* getTypeName(Type type) {
190197 if (type != TYPE_NONE && type != TYPE_NONE_FORCE) {
191198 const PROXY_TYPE_TABLE* table = proxy_type_table();
192199 while (table->name != NULL) {
@@ -198,10 +205,10 @@
198205 return NULL;
199206 }
200207
201- static int parsePort(const char* string) {
202- return parsePort(string, string + strlen(string));
208+ static int parsePort(const TCHAR* string) {
209+ return parsePort(string, string + _tcslen(string));
203210 }
204- static int parsePort(const char* string, const char* end) {
211+ static int parsePort(const TCHAR* string, const TCHAR* end) {
205212 if (string > end || *string < '1' || '9' < *string)
206213 return -1;
207214 int digit = 0;
@@ -276,8 +283,8 @@
276283 return url;
277284 }
278285 #else
279- static String parse(const char* url, ProxyInfo& proxy) {
280- char* p = strstr((char*) url, "://");
286+ static String parse(const TCHAR* url, ProxyInfo& proxy) {
287+ TCHAR* p = _tcsstr((TCHAR*) url, _T("://"));
281288 if (p == NULL) {
282289 proxy.type = TYPE_NONE;
283290 return NULL;
@@ -286,7 +293,7 @@
286293 if (proxy.type == TYPE_NONE)
287294 return NULL;
288295 p += 3;
289- const char* start = p;
296+ const TCHAR* start = p;
290297
291298 // user:pass があれば格納する
292299 String tmp = String(start);
@@ -352,7 +359,7 @@
352359 return NULL;
353360 StringBuffer buffer;
354361 buffer.append(getTypeName(type));
355- buffer.append("://");
362+ buffer.append(_T("://"));
356363 if (type != TYPE_SSL) {
357364 if (user != NULL) {
358365 urlencode(user, buffer);
@@ -366,9 +373,9 @@
366373 buffer.append(host);
367374 }
368375 else {
369- buffer.append("[");
376+ buffer.append(_T("["));
370377 buffer.append(host);
371- buffer.append("]");
378+ buffer.append(_T("]"));
372379 }
373380 if (port != 0) {
374381 buffer.append(':');
@@ -398,9 +405,9 @@
398405 }
399406 }
400407
401- static String urldecode(const char* start, const char* end) {
402- char* buffer = (char*) alloca((end - start) * 3 + 1);
403- char* dst = buffer;
408+ static String urldecode(const TCHAR* start, const TCHAR* end) {
409+ TCHAR* buffer = (TCHAR*) alloca(sizeof(TCHAR) * ((end - start) * 3 + 1));
410+ TCHAR* dst = buffer;
404411 int c1, c2;
405412 while (start < end) {
406413 if (*start == '%' && start + 2 < end && (c1 = hexdigit(start[1])) != -1 && (c2 = hexdigit(start[2])) != -1) {
@@ -407,9 +414,11 @@
407414 *dst++ = (char) (c1 << 4 | c2);
408415 start += 3;
409416 }else{
410- if (IsDBCSLeadByte(*start)) {
417+#if !defined(UNICODE)
418+ if (::IsDBCSLeadByte(*start)) {
411419 *dst++ = *start++;
412420 }
421+#endif
413422 *dst++ = *start++;
414423 }
415424 }
@@ -416,16 +425,18 @@
416425 *dst = '\0';
417426 return buffer;
418427 }
419- static String urlencode(const char* string, StringBuffer& buffer) {
420- static const char table[] = "0123456789ABCDEF";
421- const char* start = string;
428+ static String urlencode(const TCHAR* string, StringBuffer& buffer) {
429+ static const TCHAR table[] = _T("0123456789ABCDEF");
430+ const TCHAR* start = string;
422431 while (*string != '\0') {
423432 if ('0' <= *string && *string <= '9'
424433 || 'A' <= *string && *string <= 'Z'
425434 || 'a' <= *string && *string <= 'z'
426435 || *string == '-' || *string == '.' || *string == '_') {
436+#if !defined(UNICODE)
427437 }else if (::IsDBCSLeadByte(*string)) {
428438 string++;
439+#endif
429440 }else{
430441 if (start < string) {
431442 buffer.append(start, string - start);
@@ -485,26 +496,26 @@
485496 ~ConnectionInfo() {
486497 delete[] buffer;
487498 }
488- void fillBuffer(char* buffer, int bufferLength) {
489- fillBuffer(buffer, bufferLength, "ssh");
499+ void fillBuffer(char* _buffer, int bufferLength) {
500+ fillBuffer(_buffer, bufferLength, "ssh");
490501 }
491- void fillBuffer(char* buffer, int bufferLength, const char *portname) {
492- fillBuffer(buffer, bufferLength, "ssh", AF_UNSPEC);
502+ void fillBuffer(char* _buffer, int bufferLength, const char *portname) {
503+ fillBuffer(_buffer, bufferLength, "ssh", AF_UNSPEC);
493504 }
494- void fillBuffer(char* buffer, int bufferLength, const char *portname, int addr_family) {
495- struct servent* sv;
505+ void fillBuffer(char* _buffer, int bufferLength, const char *portname, int addr_family) {
506+ struct servent* sv = getservbyname(portname, "tcp");
496507 struct addrinfo* res;
497508 struct addrinfo* res0;
498509 struct addrinfo hints;
499510 int portnum = 0;
500- if (sv = getservbyname(portname, "tcp")) {
511+ if (sv) {
501512 portnum = sv->s_port;
502513 }
503514 else {
504515 portnum = atoi(portname);
505516 }
506- memset(buffer, 0, bufferLength);
507- DUMMYHOSTENT* dst = (DUMMYHOSTENT*) buffer;
517+ memset(_buffer, 0, bufferLength);
518+ DUMMYHOSTENT* dst = (DUMMYHOSTENT*) _buffer;
508519 dst->addr = addr;
509520 dst->addr6 = addr6;
510521 dst->addrlist[0] = (char*) &dst->addr;
@@ -554,7 +565,7 @@
554565 case AF_UNSPEC:
555566 default:
556567 memset(&hints, 0, sizeof hints);
557- getaddrinfo(proxy.host, NULL, &hints, &res0);
568+ getaddrinfo((u8)proxy.host, NULL, &hints, &res0);
558569 if (res0) {
559570 int flag = 0;
560571 for (res = res0; res; res = res->ai_next) {
@@ -591,7 +602,7 @@
591602 break;
592603 }
593604
594- strcpy_s(dst->hostname, bufferLength - sizeof (DUMMYHOSTENT), realhost);
605+ strcpy_s(dst->hostname, bufferLength - sizeof (DUMMYHOSTENT), (u8)realhost);
595606 }
596607 };
597608 class ConnectionInfoHolder {
@@ -665,7 +676,7 @@
665676 ::LeaveCriticalSection(&section);
666677 return info;
667678 }
668- ConnectionInfo* find(const char* url) {
679+ ConnectionInfo* find(const TCHAR* url) {
669680 ::EnterCriticalSection(&section);
670681 ConnectionInfo* info = table.get(url);
671682 ::LeaveCriticalSection(&section);
@@ -734,20 +745,18 @@
734745 protected:
735746 virtual bool dispatch(int message, int wParam, long lParam) {
736747 if (message == WM_COMMAND && wParam == MAKEWPARAM(IDC_REFER, BN_CLICKED)) {
737- char buffer[1024];
738- char uimsg[MAX_UIMSG];
739- OPENFILENAME ofn = {
740- sizeof ofn,
741- *this,
742- };
748+ TCHAR buffer[1024];
749+ TCHAR uimsg[MAX_UIMSG];
750+ OPENFILENAME ofn;
751+ ofn.lStructSize = sizeof(ofn);
743752 ofn.lpstrFile = buffer;
744753 ofn.nMaxFile = countof(buffer);
745754 ofn.Flags = OFN_LONGNAMES | OFN_NONETWORKBUTTON | OFN_PATHMUSTEXIST | OFN_NOREADONLYRETURN | OFN_HIDEREADONLY;
746- UTIL_get_lang_msg("MSG_LOGFILE_SELECT", uimsg, sizeof(uimsg),
747- "Select Logfile");
755+ UTIL_get_lang_msg("MSG_LOGFILE_SELECT", uimsg, _countof(uimsg),
756+ _T("Select Logfile"));
748757 ofn.lpstrTitle = uimsg;
749758 if (logfile != NULL) {
750- strcpy_s(buffer, sizeof buffer, logfile);
759+ _tcscpy_s(buffer, _countof(buffer), (tc)logfile);
751760 }else{
752761 buffer[0] = '\0';
753762 }
@@ -764,14 +773,33 @@
764773 return Dialog::dispatch(message, wParam, lParam);
765774 }
766775 virtual bool onInitDialog() {
767- char uimsg[MAX_UIMSG], uitmp[MAX_UIMSG];
768- LOGFONT logfont;
776+ const static DlgTextInfo text_info[] = {
777+ { 0, "DLG_OTHER_TITLE" },
778+ { IDC_GRP_COMMON, "DLG_OTHER_COMMON" },
779+ { IDC_TIMEOUT_LABEL, "DLG_OTHER_TIMEOUT" },
780+ { IDC_TIMEOUT_SECONDS, "DLG_OTHER_SECOND" },
781+ { IDC_LOGFILE_LABEL, "DLG_OTHER_LOG" },
782+ { IDC_REFER, "DLG_OTHER_REFER" },
783+ { IDC_GRP_SOCKS, "DLG_OTHER_SOCKS" },
784+ { IDC_RESOLVE_LABEL, "DLG_OTHER_RESOLV" },
785+ { IDC_GRP_TELNET, "DLG_OTHER_TELNET" },
786+ { IDC_HOSTNAME_LABEL, "DLG_OTHER_HOST" },
787+ { IDC_USERNAME_LABEL, "DLG_OTHER_USER" },
788+ { IDC_PASSWORD_LABEL, "DLG_OTHER_PASS" },
789+ { IDC_CONNECTED_LABEL, "DLG_OTHER_CONNECT" },
790+ { IDC_ERROR_LABEL, "DLG_OTHER_ERROR" },
791+// { IDOK, "BTN_OK" },
792+// { IDCANCEL, "BTN_CANCEL" },
793+ };
794+ TCHAR uimsg[MAX_UIMSG];
795+// TCHAR uitmp[MAX_UIMSG];
796+ LOGFONTA logfont;
769797 HFONT font;
770798
771799 Dialog::onInitDialog();
772800
773801 font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
774- GetObject(font, sizeof(LOGFONT), &logfont);
802+ GetObject(font, sizeof(logfont), &logfont);
775803 if (UTIL_get_lang_font("DLG_TAHOMA_FONT", HWND(), &logfont, &DlgFont)) {
776804 SendDlgItemMessage(IDC_GRP_COMMON, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
777805 SendDlgItemMessage(IDC_TIMEOUT_LABEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
@@ -801,6 +829,9 @@
801829 DlgFont = NULL;
802830 }
803831
832+ HWND hWnd = (HWND)this;
833+ SetDlgTexts(hWnd, text_info, _countof(text_info), UILanguageFile);
834+#if 0
804835 GetWindowText(uitmp, sizeof(uitmp));
805836 UTIL_get_lang_msg("DLG_OTHER_TITLE", uimsg, sizeof(uimsg), uitmp);
806837 SetWindowText(uimsg);
@@ -849,6 +880,7 @@
849880 GetDlgItemText(IDCANCEL, uitmp, sizeof(uitmp));
850881 UTIL_get_lang_msg("BTN_CANCEL", uimsg, sizeof(uimsg), uitmp);
851882 SetDlgItemText(IDCANCEL, uimsg);
883+#endif
852884
853885 host = GetDlgItem(IDC_HOSTNAME);
854886 user = GetDlgItem(IDC_USERNAME);
@@ -860,22 +892,22 @@
860892 SetDlgItemInt(IDC_TIMEOUT, timeout, false);
861893
862894 resolveCombo <<= GetDlgItem(IDC_RESOLVE);
863- UTIL_get_lang_msg("DLG_OTHER_RESOLV_AUTO", uimsg, sizeof(uimsg), "auto resolve");
895+ UTIL_get_lang_msg("DLG_OTHER_RESOLV_AUTO", uimsg, _countof(uimsg), _T("auto resolve"));
864896 resolveCombo.addString(uimsg);
865- UTIL_get_lang_msg("DLG_OTHER_RESOLV_REMOTE", uimsg, sizeof(uimsg), "resolve remote");
897+ UTIL_get_lang_msg("DLG_OTHER_RESOLV_REMOTE", uimsg, _countof(uimsg), _T("resolve remote"));
866898 resolveCombo.addString(uimsg);
867- UTIL_get_lang_msg("DLG_OTHER_RESOLV_LOCAL", uimsg, sizeof(uimsg), "resolve local");
899+ UTIL_get_lang_msg("DLG_OTHER_RESOLV_LOCAL", uimsg, _countof(uimsg), _T("resolve local"));
868900 resolveCombo.addString(uimsg);
869901 resolveCombo.setCurSel(resolve);
870902
871- host.SetWindowText(HostnamePrompt);
872- user.SetWindowText(UsernamePrompt);
873- pass.SetWindowText(PasswordPrompt);
874- conn.SetWindowText(ConnectedMessage);
875- erro.SetWindowText(ErrorMessage);
903+ host.SetWindowText((tc)HostnamePrompt);
904+ user.SetWindowText((tc)UsernamePrompt);
905+ pass.SetWindowText((tc)PasswordPrompt);
906+ conn.SetWindowText((tc)ConnectedMessage);
907+ erro.SetWindowText((tc)ErrorMessage);
876908
877909 if (logfile != NULL)
878- log.SetWindowText(logfile);
910+ log.SetWindowText((tc)logfile);
879911
880912 return true;
881913 }
@@ -885,9 +917,9 @@
885917 || pass.GetWindowTextLength() == 0
886918 || conn.GetWindowTextLength() == 0
887919 || erro.GetWindowTextLength() == 0) {
888- char uimsg[MAX_UIMSG];
889- UTIL_get_lang_msg("MSG_EMPTY_PARAMETER", uimsg, sizeof(uimsg),
890- "Some parameters are empty!");
920+ TCHAR uimsg[MAX_UIMSG];
921+ UTIL_get_lang_msg("MSG_EMPTY_PARAMETER", uimsg, _countof(uimsg),
922+ _T("Some parameters are empty!"));
891923 MessageBox(uimsg, FileVersion::getOwnVersion().getProductName(), MB_OK | MB_ICONERROR);
892924 return;
893925 }
@@ -962,14 +994,15 @@
962994 return Dialog::dispatch(message, wParam, lParam);
963995 }
964996 virtual bool onInitDialog() {
965- char uimsg[MAX_UIMSG], uitmp[MAX_UIMSG];
966- LOGFONT logfont;
997+ TCHAR uimsg[MAX_UIMSG];
998+// TCHAR uitmp[MAX_UIMSG];
999+ LOGFONTA logfont;
9671000 HFONT font;
9681001
9691002 Dialog::onInitDialog();
9701003
9711004 font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
972- GetObject(font, sizeof(LOGFONT), &logfont);
1005+ GetObject(font, sizeof(logfont), &logfont);
9731006 if (UTIL_get_lang_font("DLG_TAHOMA_FONT", HWND(), &logfont, &DlgFont)) {
9741007 SendDlgItemMessage(IDC_URL_LABEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
9751008 SendDlgItemMessage(IDC_URL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
@@ -991,8 +1024,23 @@
9911024 DlgFont = NULL;
9921025 }
9931026
1027+ const static DlgTextInfo text_info[] = {
1028+ { 0, "DLG_SETUP_TITLE" },
1029+ { IDC_URL_LABEL, "DLG_SETUP_URL" },
1030+ { IDC_TYPE_LEBEL, "DLG_SETUP_TYPE" },
1031+ { IDC_HOSTNAME_LABEL, "DLG_SETUP_HOST" },
1032+ { IDC_PORT_LABEL, "DLG_SETUP_PORT" },
1033+ { IDC_USERNAME_LABEL, "DLG_SETUP_USER" },
1034+ { IDC_PASSWORD_LABEL, "DLG_SETUP_PASS" },
1035+ { IDC_OPTIONS, "DLG_SETUP_OTHER" },
1036+// { IDOK, "BTN_OK" },
1037+// { IDCANCEL, "BTN_CANCEL" },
1038+ };
1039+ HWND hWnd = (HWND)this;
1040+ SetDlgTexts(hWnd, text_info, _countof(text_info), UILanguageFile);
1041+#if 0
9941042 GetWindowText(uitmp, sizeof(uitmp));
995- UTIL_get_lang_msg("DLG_SETUP_TITLE", uimsg, sizeof(uimsg), uitmp);
1043+ UTIL_get_lang_msgT("DLG_SETUP_TITLE", uimsg, sizeof(uimsg), uitmp);
9961044 SetWindowText(uimsg);
9971045 GetDlgItemText(IDC_URL_LABEL, uitmp, sizeof(uitmp));
9981046 UTIL_get_lang_msg("DLG_SETUP_URL", uimsg, sizeof(uimsg), uitmp);
@@ -1021,7 +1069,7 @@
10211069 GetDlgItemText(IDCANCEL, uitmp, sizeof(uitmp));
10221070 UTIL_get_lang_msg("BTN_CANCEL", uimsg, sizeof(uimsg), uitmp);
10231071 SetDlgItemText(IDCANCEL, uimsg);
1024-
1072+#endif
10251073 url <<= GetDlgItem(IDC_URL);
10261074 type <<= GetDlgItem(IDC_TYPE);
10271075 host <<= GetDlgItem(IDC_HOSTNAME);
@@ -1030,18 +1078,18 @@
10301078 pass <<= GetDlgItem(IDC_PASSWORD);
10311079
10321080 lock = true;
1033- UTIL_get_lang_msg("MSG_TYPE_NONE", uimsg, sizeof(uimsg), "Without Proxy");
1081+ UTIL_get_lang_msg("MSG_TYPE_NONE", uimsg, _countof(uimsg), __T("Without Proxy"));
10341082 type.addString(uimsg);
1035- type.addString("HTTP");
1036- type.addString("TELNET");
1037- type.addString("SOCKS4");
1038- type.addString("SOCKS5");
1083+ type.addString(_T("HTTP"));
1084+ type.addString(_T("TELNET"));
1085+ type.addString(_T("SOCKS4"));
1086+ type.addString(_T("SOCKS5"));
10391087 if (SSLSocket::isEnabled()) {
1040- type.addString("SSL");
1041- type.addString("HTTP+SSL");
1042- type.addString("TELNET+SSL");
1043- type.addString("SOCKS4+SSL");
1044- type.addString("SOCKS5+SSL");
1088+ type.addString(_T("SSL"));
1089+ type.addString(_T("HTTP+SSL"));
1090+ type.addString(_T("TELNET+SSL"));
1091+ type.addString(_T("SOCKS4+SSL"));
1092+ type.addString(_T("SOCKS5+SSL"));
10451093 }
10461094 type.setCurSel(proxy.type);
10471095
@@ -1049,8 +1097,8 @@
10491097 if (proxy.host != NULL) {
10501098 host.SetWindowText(proxy.host);
10511099 if (proxy.port != 0) {
1052- char buffer[16];
1053- _itoa_s(proxy.port, buffer, sizeof buffer, 10);
1100+ TCHAR buffer[16];
1101+ _itot_s(proxy.port, buffer, _countof(buffer), 10);
10541102 port.SetWindowText(buffer);
10551103 }
10561104 if (proxy.user != NULL) {
@@ -1066,17 +1114,17 @@
10661114 return true;
10671115 }
10681116 virtual void onOK() {
1069- char uimsg[MAX_UIMSG];
1117+ TCHAR uimsg[MAX_UIMSG];
10701118 if (proxy.type != ProxyInfo::TYPE_NONE && proxy.type != ProxyInfo::TYPE_SSL) {
10711119 if (proxy.host == NULL) {
1072- UTIL_get_lang_msg("MSG_EMPTY_HOSTNAME", uimsg, sizeof(uimsg),
1073- "Hostname is empty!");
1120+ UTIL_get_lang_msg("MSG_EMPTY_HOSTNAME", uimsg, _countof(uimsg),
1121+ _T("Hostname is empty!"));
10741122 MessageBox(uimsg, FileVersion::getOwnVersion().getProductName(), MB_OK | MB_ICONERROR);
10751123 return;
10761124 }
10771125 if (port.GetWindowTextLength() != 0 && proxy.port <= 0) {
1078- UTIL_get_lang_msg("MSG_ILLEGAL_PORT", uimsg, sizeof(uimsg),
1079- "Illegal port number!");
1126+ UTIL_get_lang_msg("MSG_ILLEGAL_PORT", uimsg, _countof(uimsg),
1127+ _T("Illegal port number!"));
10801128 MessageBox(uimsg, FileVersion::getOwnVersion().getProductName(), MB_OK | MB_ICONERROR);
10811129 return;
10821130 }
@@ -1177,9 +1225,9 @@
11771225 }
11781226 String urlS = proxy.generateURL();
11791227 if (urlS == NULL) {
1180- urlS = "none:///";
1228+ urlS = _T("none:///");
11811229 }
1182- url.SetWindowText(urlS);
1230+ url.SetWindowText((tc)urlS);
11831231 }
11841232 public:
11851233 ProxyInfo proxy;
@@ -1197,15 +1245,15 @@
11971245 HFONT DlgFont;
11981246 virtual bool onInitDialog() {
11991247 String buf;
1200- char *buf2;
1201- const char *ver;
1248+ TCHAR *buf2;
1249+ const TCHAR *ver;
12021250 int n, a, b, c, d, len;
1203- char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], uimsg3[MAX_UIMSG];
1204- LOGFONT logfont;
1251+ TCHAR uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], uimsg3[MAX_UIMSG];
1252+ LOGFONTA logfont;
12051253 HFONT font;
12061254
12071255 font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
1208- GetObject(font, sizeof(LOGFONT), &logfont);
1256+ GetObject(font, sizeof(logfont), &logfont);
12091257 if (UTIL_get_lang_font("DLG_TAHOMA_FONT", HWND(), &logfont, &DlgFont)) {
12101258 SendDlgItemMessage(IDC_VERSION, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
12111259 SendDlgItemMessage(IDOK, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
@@ -1214,31 +1262,31 @@
12141262 DlgFont = NULL;
12151263 }
12161264
1217- GetWindowText(uimsg2, sizeof(uimsg2));
1218- UTIL_get_lang_msg("DLG_ABOUT_TITLE", uimsg, sizeof(uimsg), uimsg2);
1265+ GetWindowText(uimsg2, _countof(uimsg2));
1266+ UTIL_get_lang_msg("DLG_ABOUT_TITLE", uimsg, _countof(uimsg), uimsg2);
12191267 SetWindowText(uimsg);
12201268
1221- UTIL_get_lang_msg("DLG_ABOUT_EXTENSION", uimsg, sizeof(uimsg),
1222- "Tera Term proxy extension");
1223- UTIL_get_lang_msg("DLG_ABOUT_YEBISUYA", uimsg2, sizeof(uimsg2),
1224- "YebisuyaHompo");
1225- UTIL_get_lang_msg("DLG_ABOUT_HOMEPAGE", uimsg3, sizeof(uimsg3),
1226- "TTProxy home page");
1269+ UTIL_get_lang_msg("DLG_ABOUT_EXTENSION", uimsg, _countof(uimsg),
1270+ _T("Tera Term proxy extension"));
1271+ UTIL_get_lang_msg("DLG_ABOUT_YEBISUYA", uimsg2, _countof(uimsg2),
1272+ _T("YebisuyaHompo"));
1273+ UTIL_get_lang_msg("DLG_ABOUT_HOMEPAGE", uimsg3, _countof(uimsg3),
1274+ _T("TTProxy home page"));
12271275 buf = GetDlgItemText(IDC_VERSION);
12281276 len = buf.length() + 50;
1229- buf2 = (char *)_alloca(len);
1277+ buf2 = (TCHAR *)_alloca(sizeof(TCHAR) * len);
12301278 if (buf2 == NULL) {
12311279 return true;
12321280 }
12331281 ver = FileVersion::getOwnVersion().getFileVersion();
1234- n = sscanf_s(ver, "%d, %d, %d, %d", &a, &b, &c, &d);
1282+ n = _stscanf_s(ver, _T("%d, %d, %d, %d"), &a, &b, &c, &d);
12351283 if (n == 4) {
1236- sprintf_s(buf2, len, buf, uimsg, a, b, c, d, uimsg2, uimsg3);
1284+ _stprintf_s(buf2, len, buf, uimsg, a, b, c, d, uimsg2, uimsg3);
12371285 }
12381286 SetDlgItemText(IDC_VERSION, (n == 4) ? buf2 : buf);
12391287
1240- GetDlgItemText(IDOK, uimsg, sizeof(uimsg));
1241- UTIL_get_lang_msg("BTN_OK", uimsg, sizeof(uimsg),"OK");
1288+ GetDlgItemText(IDOK, uimsg, _countof(uimsg));
1289+ UTIL_get_lang_msg("BTN_OK", uimsg, _countof(uimsg), _T("OK"));
12421290 SetDlgItemText(IDOK, uimsg);
12431291
12441292 return true;
@@ -1277,7 +1325,6 @@
12771325 }
12781326
12791327 int sendToSocket(SOCKET s, const unsigned char* buffer, int size) {
1280- int i = 0;
12811328 Logger::log("send", buffer, size);
12821329 return _sendToSocket(s, buffer, size);
12831330 }
@@ -1287,20 +1334,20 @@
12871334 int len;
12881335 va_list arglist;
12891336 va_start(arglist, format);
1290- len = wvsprintf(buf, format, arglist);
1337+ len = wvsprintfA(buf, format, arglist);
12911338 va_end(arglist);
12921339 Logger::log("send", buf);
12931340 return _sendToSocket(s, (const unsigned char*) buf, len);
12941341 }
12951342
1296- int recieveFromSocketTimeout(SOCKET s, unsigned char* buffer, int size, int timeout) {
1343+ int recieveFromSocketTimeout(SOCKET s, unsigned char* buffer, int size, int _timeout) {
12971344 int ready = 0;
12981345 while (!ready) {
1299- struct timeval tv = {timeout, 0};
1346+ struct timeval tv = {_timeout, 0};
13001347 fd_set fd;
13011348 FD_ZERO(&fd);
13021349 FD_SET(s, &fd);
1303- switch (select((int) (s + 1), &fd, NULL, NULL, timeout > 0 ? &tv : NULL)) {
1350+ switch (select((int) (s + 1), &fd, NULL, NULL, _timeout > 0 ? &tv : NULL)) {
13041351 case SOCKET_ERROR:
13051352 return SOCKET_ERROR;
13061353 case 0:
@@ -1348,13 +1395,13 @@
13481395 return 0;
13491396 }
13501397
1351- int wait_for_prompt(SOCKET s, String prompts[], int count, int timeout /* sec */) {
1398+ int wait_for_prompt(SOCKET s, String prompts[], int count, int _timeout /* sec */) {
13521399 char buf[1024];
13531400 while (1) {
13541401 char *dst = buf;
13551402 char *end = buf + sizeof buf - 1;
13561403 while (dst < end) {
1357- switch (recieveFromSocketTimeout(s, (unsigned char*) dst, 1, timeout)) { /* recv one-by-one */
1404+ switch (recieveFromSocketTimeout(s, (unsigned char*) dst, 1, _timeout)) { /* recv one-by-one */
13581405 case SOCKET_ERROR:
13591406 if (WSAGetLastError() != WSAEWOULDBLOCK) {
13601407 return SOCKET_ERROR;
@@ -1376,7 +1423,8 @@
13761423 *dst = '\0';
13771424 Logger::log("recv", buf);
13781425 for (i = 0; i < count; i++) {
1379- char* found = strstr(buf, prompts[i]);
1426+ u8 promptU8 = (const TCHAR *)prompts[i];
1427+ char* found = strstr(buf, promptU8);
13801428 if (found != NULL) {
13811429 return i;
13821430 }
@@ -1389,13 +1437,16 @@
13891437 static const char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
13901438 char buf[1024];
13911439 int status_code;
1392- if (sendToSocketFormat(s, strchr(realhost,':')?"CONNECT [%s]:%d HTTP/1.1\r\n":"CONNECT %s:%d HTTP/1.1\r\n", (const char *)realhost, realport) == SOCKET_ERROR)
1440+ u8 realhostU8 = (const TCHAR *)realhost;
1441+ if (sendToSocketFormat(s, strchr((const char *)realhostU8,':')?"CONNECT [%s]:%d HTTP/1.1\r\n":"CONNECT %s:%d HTTP/1.1\r\n", (const char *)realhostU8, realport) == SOCKET_ERROR)
13931442 return SOCKET_ERROR;
1394- if (sendToSocketFormat(s, strchr(realhost,':')?"Host: [%s]:%d\r\n":"Host: %s:%d\r\n", (const char *)realhost, realport) == SOCKET_ERROR)
1443+ if (sendToSocketFormat(s, strchr((const char *)realhostU8,':')?"Host: [%s]:%d\r\n":"Host: %s:%d\r\n", (const char *)realhostU8, realport) == SOCKET_ERROR)
13951444 return SOCKET_ERROR;
13961445 if (proxy.user != NULL) {
1397- int userlen = strlen(proxy.user);
1398- int passlen = strlen(proxy.pass);
1446+ u8 proxy_user = (const TCHAR *)proxy.user;
1447+ u8 proxy_pass = (const TCHAR *)proxy.pass;
1448+ int userlen = strlen(proxy_user);
1449+ int passlen = strlen(proxy_pass);
13991450 int authlen = userlen + 1 + passlen;
14001451 int encodedlen = (authlen + 2) / 3 * 4;
14011452 char* auth = (char*) alloca(authlen + 1);
@@ -1404,10 +1455,10 @@
14041455 char *dst = encoded;
14051456 int bits = 0;
14061457 int data = 0;
1407- strcpy_s(auth, authlen + 1, proxy.user);
1458+ strcpy_s(auth, authlen + 1, proxy_user);
14081459 auth[userlen] = ':';
1409- strcpy_s(auth + userlen + 1, passlen + 1, proxy.pass);
1410-
1460+ strcpy_s(auth + userlen + 1, passlen + 1, proxy_pass);
1461+
14111462 /* make base64 string */
14121463 while (*src != '\0') {
14131464 data = (data << 8) | *src++;
@@ -1422,7 +1473,7 @@
14221473 *dst++ = base64_table[0x3F & (data << (6 - bits))];
14231474 encodedlen--;
14241475 }
1425- while (encodedlen-- > 0) {
1476+ while (encodedlen-- > 0) {
14261477 *dst++ = '=';
14271478 }
14281479 *dst = '\0';
@@ -1441,12 +1492,12 @@
14411492 }
14421493 } while (strcmp(buf,"\r\n") != 0);
14431494 if (status_code != 200) {
1444- char uimsg[MAX_UIMSG];
1495+ TCHAR uimsg[MAX_UIMSG];
14451496 switch (status_code) {
14461497 case 401:
14471498 case 407:
14481499 UTIL_get_lang_msg("MSG_PROXY_UNAUTHORIZED", uimsg, sizeof(uimsg),
1449- "Proxy authorization failed!");
1500+ _T("Proxy authorization failed!"));
14501501 break;
14511502 case 400:
14521503 case 405:
@@ -1453,7 +1504,7 @@
14531504 case 406:
14541505 case 403:
14551506 UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, sizeof(uimsg),
1456- "Proxy prevent this connection!");
1507+ _T("Proxy prevent this connection!"));
14571508 break;
14581509 }
14591510 return setError(s, uimsg);
@@ -1496,7 +1547,10 @@
14961547 int auth_result;
14971548 unsigned char buf[256];
14981549 unsigned char* ptr = buf;
1499- char uimsg[MAX_UIMSG];
1550+ TCHAR uimsg[MAX_UIMSG];
1551+ u8 proxy_user = (const TCHAR *)proxy.user;
1552+ u8 proxy_pass = (const TCHAR *)proxy.pass;
1553+ u8 realhostU8 = (const TCHAR *)realhost;
15001554 *ptr++ = SOCKS5_VERSION;
15011555 if (proxy.user != NULL && proxy.pass != NULL) {
15021556 *ptr++ = 2; // support 2 auth methods : SOCKS5_AUTH_NOAUTH, SOCKS5_AUTH_USERPASS
@@ -1512,9 +1566,8 @@
15121566 return SOCKET_ERROR;
15131567
15141568 if (buf[0] != SOCKS5_VERSION || buf[1] == SOCKS5_REJECT) {
1515- char uimsg[MAX_UIMSG];
15161569 UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, sizeof(uimsg),
1517- "Proxy prevent this connection!");
1570+ _T("Proxy prevent this connection!"));
15181571 return setError(s, uimsg);
15191572 }
15201573 auth_method = buf[1];
@@ -1529,19 +1582,19 @@
15291582 /* make authentication packet */
15301583 ptr = buf;
15311584 *ptr++ = SOCKS5_AUTH_SUBNEGOVER;
1532- len = proxy.user.length();
1585+ len = strlen(proxy_user);
15331586 *ptr++ = len;
1534- strcpy_s((char*) ptr, sizeof buf - (ptr - buf), proxy.user);
1587+ strcpy_s((char*) ptr, sizeof buf - (ptr - buf), proxy_user);
15351588 ptr += len;
1536- len = proxy.pass.length();
1589+ len = strlen(proxy_pass);
15371590 *ptr++ = len;
1538- strcpy_s((char*) ptr, sizeof buf - (ptr - buf), proxy.pass);
1591+ strcpy_s((char*) ptr, sizeof buf - (ptr - buf), proxy_pass);
15391592 ptr += len;
15401593
15411594 /* send it and get answer */
1542- if (sendToSocket(s, buf, ptr - buf) == SOCKET_ERROR)
1595+ if (sendToSocket(s, buf, ptr - buf) == SOCKET_ERROR)
15431596 return SOCKET_ERROR;
1544- if (recieveFromSocket(s, buf, 2) == SOCKET_ERROR)
1597+ if (recieveFromSocket(s, buf, 2) == SOCKET_ERROR)
15451598 return SOCKET_ERROR;
15461599
15471600 /* check status */
@@ -1549,7 +1602,7 @@
15491602 break;
15501603 default:
15511604 UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, sizeof(uimsg),
1552- "Proxy prevent this connection!");
1605+ _T("Proxy prevent this connection!"));
15531606 return setError(s, uimsg);
15541607 }
15551608 if (auth_result == SOCKET_ERROR) {
@@ -1556,7 +1609,7 @@
15561609 return SOCKET_ERROR;
15571610 }else if (auth_result != 0) {
15581611 UTIL_get_lang_msg("MSG_PROXY_UNAUTHORIZED", uimsg, sizeof(uimsg),
1559- "Proxy authorization failed!");
1612+ _T("Proxy authorization failed!"));
15601613 return setError(s, uimsg);
15611614 }
15621615 /* request to connect */
@@ -1567,7 +1620,7 @@
15671620 struct addrinfo hints, *res = NULL;
15681621 if (resolve != RESOLVE_REMOTE) {
15691622 memset(&hints, 0, sizeof(hints));
1570- getaddrinfo(realhost, NULL, &hints, &res);
1623+ getaddrinfo(realhostU8, NULL, &hints, &res);
15711624 }
15721625 if (res) {
15731626 switch (res->ai_family) {
@@ -1584,6 +1637,7 @@
15841637 default:
15851638 freeaddrinfo(res);
15861639 WSASetLastError(WSAECONNREFUSED);
1640+
15871641 return SOCKET_ERROR;
15881642 break;
15891643 }
@@ -1595,9 +1649,9 @@
15951649 }
15961650 else {
15971651 *ptr++ = SOCKS5_ATYP_DOMAINNAME;
1598- len = strlen(realhost);
1652+ len = strlen(realhostU8);
15991653 *ptr++ = len;
1600- memcpy(ptr, realhost, len);
1654+ memcpy(ptr, realhostU8, len);
16011655 ptr += len;
16021656 }
16031657 *ptr++ = realport >> 8; /* DST.PORT */
@@ -1608,7 +1662,7 @@
16081662 return SOCKET_ERROR;
16091663 if (buf[0] != SOCKS5_VERSION || buf[1] != SOCKS5_REP_SUCCEEDED) { /* check reply code */
16101664 UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, sizeof(uimsg),
1611- "Proxy prevent this connection!");
1665+ _T("Proxy prevent this connection!"));
16121666 return setError(s, uimsg);
16131667 }
16141668 // buf[2] is reserved
@@ -1647,8 +1701,8 @@
16471701
16481702 int begin_relay_socks4(ProxyInfo& proxy, String realhost, unsigned short realport, SOCKET s) {
16491703 unsigned char buf[256], *ptr;
1650-
1651- /* make connect request packet
1704+ u8 realhostU8 = (const TCHAR *)realhost;
1705+ /* make connect request packet
16521706 protocol v4:
16531707 VN:1, CD:1, PORT:2, ADDR:4, USER:n, NULL:1
16541708 protocol v4a:
@@ -1661,15 +1715,15 @@
16611715 *ptr++ = realport & 0xFF;
16621716 in_addr addr;
16631717 addr.s_addr = INADDR_NONE;
1664- char ch = realhost.charAt(0);
1718+ char ch = *(const char *)realhostU8;
16651719 if ('0' <= ch && ch <= '9') {
1666- addr.s_addr = inet_addr(realhost);
1720+ addr.s_addr = inet_addr(realhostU8);
16671721 }
16681722 if (addr.s_addr != INADDR_NONE) {
16691723 memcpy(ptr, &addr, sizeof addr);
16701724 ptr += sizeof addr;
16711725 }else{
1672- struct hostent* entry = resolve != RESOLVE_REMOTE ? gethostbyname(realhost) : NULL;
1726+ struct hostent* entry = resolve != RESOLVE_REMOTE ? gethostbyname(realhostU8) : NULL;
16731727 if (entry != NULL && entry->h_addrtype == AF_INET && entry->h_length == sizeof (in_addr)) {
16741728 addr.s_addr = INADDR_LOOPBACK;
16751729 memcpy(ptr, entry->h_addr_list[0], entry->h_length);
@@ -1687,7 +1741,8 @@
16871741 }
16881742 /* username */
16891743 if (proxy.user != NULL) {
1690- strcpy_s((char*) ptr, sizeof buf - (ptr - buf), proxy.user);
1744+ u8 proxy_user = (const TCHAR *)proxy.user;
1745+ strcpy_s((char*) ptr, sizeof buf - (ptr - buf), proxy_user);
16911746 ptr += proxy.user.length() + 1;
16921747 }else{
16931748 *ptr++ = '\0';
@@ -1694,8 +1749,8 @@
16941749 }
16951750 if (addr.s_addr == INADDR_NONE) {
16961751 /* destination host name (for protocol 4a) */
1697- strcpy_s((char*) ptr, sizeof buf - (ptr - buf), realhost);
1698- ptr += strlen(realhost) + 1;
1752+ strcpy_s((char*) ptr, sizeof buf - (ptr - buf), realhostU8);
1753+ ptr += strlen(realhostU8) + 1;
16991754 }
17001755 /* send command and get response
17011756 response is: VN:1, CD:1, PORT:2, ADDR:4 */
@@ -1705,22 +1760,22 @@
17051760 if (recieveFromSocket(s, buf, 8) == SOCKET_ERROR) {
17061761 return SOCKET_ERROR;
17071762 }
1708- char uimsg[MAX_UIMSG];
1709- uimsg[0] = NULL;
1763+ TCHAR uimsg[MAX_UIMSG];
1764+ uimsg[0] = 0;
17101765 if (buf[0] != 0) {
1711- UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, sizeof(uimsg),
1712- "Proxy prevent this connection!");
1766+ UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, _countof(uimsg),
1767+ _T("Proxy prevent this connection!"));
17131768 }else if (buf[1] == SOCKS4_REP_IDENT_FAIL || buf[1] == SOCKS4_REP_USERID) {
1714- UTIL_get_lang_msg("MSG_PROXY_UNAUTHORIZED", uimsg, sizeof(uimsg),
1715- "Proxy authorization failed!");
1769+ UTIL_get_lang_msg("MSG_PROXY_UNAUTHORIZED", uimsg, _countof(uimsg),
1770+ _T("Proxy authorization failed!"));
17161771 }else if (buf[1] != SOCKS4_REP_SUCCEEDED) {
1717- UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, sizeof(uimsg),
1718- "Proxy prevent this connection!");
1772+ UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, _countof(uimsg),
1773+ _T("Proxy prevent this connection!"));
17191774 }
1720- if (uimsg[0] != NULL) {
1775+ if (uimsg[0] != 0) {
17211776 return setError(s, uimsg);
17221777 }
1723-
1778+
17241779 /* Conguraturation, connected via SOCKS4 server! */
17251780 return 0;
17261781 }
@@ -1727,20 +1782,23 @@
17271782
17281783 int begin_relay_telnet(ProxyInfo& proxy, String realhost, unsigned short realport, SOCKET s) {
17291784 int err = 0;
1730- char uimsg[MAX_UIMSG];
1785+ TCHAR uimsg[MAX_UIMSG];
1786+ u8 realhostU8 = (const TCHAR *)realhost;
1787+ u8 proxy_user = (const TCHAR *)proxy.user;
1788+ u8 proxy_pass = (const TCHAR *)proxy.pass;
17311789
17321790 while (!err) {
17331791 switch (wait_for_prompt(s, prompt_table, countof(prompt_table), 10)) {
17341792 case 0: /* Hostname prompt */
1735- if (sendToSocketFormat(s, strchr(realhost,':')?"[%s]:%d\n":"%s:%d\n", (const char *)realhost, realport) == SOCKET_ERROR)
1793+ if (sendToSocketFormat(s, strchr(realhostU8,':')?"[%s]:%d\n":"%s:%d\n", (const char *)realhostU8, realport) == SOCKET_ERROR)
17361794 return SOCKET_ERROR;
17371795 break;
17381796 case 1: /* Username prompt */
1739- if (sendToSocketFormat(s, "%s\n", (const char *)proxy.user) == SOCKET_ERROR)
1797+ if (sendToSocketFormat(s, "%s\n", (const char *)proxy_user) == SOCKET_ERROR)
17401798 return SOCKET_ERROR;
17411799 break;
17421800 case 2: /* Password prompt */
1743- if (sendToSocketFormat(s, "%s\n", (const char *)proxy.pass) == SOCKET_ERROR)
1801+ if (sendToSocketFormat(s, "%s\n", (const char *)proxy_pass) == SOCKET_ERROR)
17441802 return SOCKET_ERROR;
17451803 break;
17461804 case 3: /* Established message */
@@ -1752,11 +1810,11 @@
17521810 }
17531811 }
17541812 UTIL_get_lang_msg("MSG_PROXY_BAD_REQUEST", uimsg, sizeof(uimsg),
1755- "Proxy prevent this connection!");
1813+ _T("Proxy prevent this connection!"));
17561814 return setError(s, uimsg);
17571815 }
17581816
1759- int setError(SOCKET s, char *p) {
1817+ int setError(SOCKET s, TCHAR *p) {
17601818 if (*p != NULL)
17611819 showMessage(p);
17621820 HWND window;
@@ -1771,7 +1829,7 @@
17711829 WSASetLastError(WSAECONNREFUSED);
17721830 return SOCKET_ERROR;
17731831 }
1774- void showMessage(char *p) {
1832+ void showMessage(TCHAR *p) {
17751833 if (shower != NULL) {
17761834 shower->showMessage(p);
17771835 }
@@ -1814,7 +1872,7 @@
18141872 struct sockaddr_in* in = (struct sockaddr_in*) name;
18151873 info = connectioninfolist.get(in->sin_addr);
18161874 if (info == NULL && defaultProxy.type != ProxyInfo::TYPE_NONE) {
1817- info = new ConnectionInfo(defaultProxy, inet_ntoa(in->sin_addr));
1875+ info = new ConnectionInfo(defaultProxy, String((tc)inet_ntoa(in->sin_addr)));
18181876 holder = info;
18191877 }
18201878 }
@@ -1824,8 +1882,8 @@
18241882 if (info == NULL && defaultProxy.type != ProxyInfo::TYPE_NONE) {
18251883 DWORD bufflen = 64;
18261884 char* buff = new char[64];
1827- WSAAddressToString((struct sockaddr*)name, sizeof(struct sockaddr_in6), NULL, buff, &bufflen);
1828- info = new ConnectionInfo(defaultProxy, buff);
1885+ WSAAddressToStringA((struct sockaddr*)name, sizeof(struct sockaddr_in6), NULL, buff, &bufflen);
1886+ info = new ConnectionInfo(defaultProxy, String((tc)buff));
18291887 holder = info;
18301888 }
18311889 }
@@ -1833,7 +1891,7 @@
18331891 if (info->proxy.type == ProxyInfo::TYPE_NONE_FORCE) {
18341892 info = NULL;
18351893 }else{
1836- const char* hostname;
1894+ u8 hostname;
18371895 if (info->proxy.type == ProxyInfo::TYPE_SSL) {
18381896 hostname = info->realhost;
18391897 }else{
@@ -1918,147 +1976,147 @@
19181976 return SOCKET_ERROR;
19191977 }
19201978 SSLSocket* ssl = new SSLSocket();
1921- if (!ssl->connect(s, info->realhost)) {
1979+ if (!ssl->connect(s, (u8)info->realhost)) {
19221980 shutdown(s, SD_BOTH);
19231981 int error_code = ssl->get_verify_result();
1924- char uimsg[MAX_UIMSG];
1982+ TCHAR uimsg[MAX_UIMSG];
19251983 delete ssl;
19261984 switch (error_code) {
19271985 case IDS_UNABLE_TO_GET_ISSUER_CERT:
19281986 UTIL_get_lang_msg("MSG_UNABLE_TO_GET_ISSUER_CERT", uimsg, sizeof(uimsg),
1929- "Unable to get Issuer Certificate");
1987+ _T("Unable to get Issuer Certificate"));
19301988 break;
19311989 case IDS_UNABLE_TO_GET_CRL:
19321990 UTIL_get_lang_msg("MSG_UNABLE_TO_GET_CRL", uimsg, sizeof(uimsg),
1933- "Unable to get Certificate CRL");
1991+ _T("Unable to get Certificate CRL"));
19341992 break;
19351993 case IDS_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
19361994 UTIL_get_lang_msg("MSG_UNABLE_TO_DECRYPT_CERT_SIGNATURE", uimsg, sizeof(uimsg),
1937- "Unable to decrypt Certificate's Signature");
1995+ _T("Unable to decrypt Certificate's Signature"));
19381996 break;
19391997 case IDS_UNABLE_TO_DECRYPT_CRL_SIGNATURE:
19401998 UTIL_get_lang_msg("MSG_UNABLE_TO_DECRYPT_CRL_SIGNATURE", uimsg, sizeof(uimsg),
1941- "Unable to decrypt CRL's Signature");
1999+ _T("Unable to decrypt CRL's Signature"));
19422000 break;
19432001 case IDS_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
19442002 UTIL_get_lang_msg("MSG_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY", uimsg, sizeof(uimsg),
1945- "Unable to decode Issuer Public Key");
2003+ _T("Unable to decode Issuer Public Key"));
19462004 break;
19472005 case IDS_CERT_SIGNATURE_FAILURE:
19482006 UTIL_get_lang_msg("MSG_CERT_SIGNATURE_FAILURE", uimsg, sizeof(uimsg),
1949- "Certificate Signature failure");
2007+ _T("Certificate Signature failure"));
19502008 break;
19512009 case IDS_CRL_SIGNATURE_FAILURE:
19522010 UTIL_get_lang_msg("MSG_CRL_SIGNATURE_FAILURE", uimsg, sizeof(uimsg),
1953- "CRL Signature failure");
2011+ _T("CRL Signature failure"));
19542012 break;
19552013 case IDS_CERT_NOT_YET_VALID:
19562014 UTIL_get_lang_msg("MSG_CERT_NOT_YET_VALID", uimsg, sizeof(uimsg),
1957- "Certificate is not yet valid");
2015+ _T("Certificate is not yet valid"));
19582016 break;
19592017 case IDS_CERT_HAS_EXPIRED:
19602018 UTIL_get_lang_msg("MSG_CERT_HAS_EXPIRED", uimsg, sizeof(uimsg),
1961- "Certificate has expired");
2019+ _T("Certificate has expired"));
19622020 break;
19632021 case IDS_CRL_NOT_YET_VALID:
19642022 UTIL_get_lang_msg("MSG_CRL_NOT_YET_VALID", uimsg, sizeof(uimsg),
1965- "CRL is not yet valid");
2023+ _T("CRL is not yet valid"));
19662024 break;
19672025 case IDS_CRL_HAS_EXPIRED:
19682026 UTIL_get_lang_msg("MSG_CRL_HAS_EXPIRED", uimsg, sizeof(uimsg),
1969- "CRL has expired");
2027+ _T("CRL has expired"));
19702028 break;
19712029 case IDS_ERROR_IN_CERT_NOT_BEFORE_FIELD:
19722030 UTIL_get_lang_msg("MSG_ERROR_IN_CERT_NOT_BEFORE_FIELD", uimsg, sizeof(uimsg),
1973- "Format error in Certificate's notBefore field");
2031+ _T("Format error in Certificate's notBefore field"));
19742032 break;
19752033 case IDS_ERROR_IN_CERT_NOT_AFTER_FIELD:
19762034 UTIL_get_lang_msg("MSG_ERROR_IN_CERT_NOT_AFTER_FIELD", uimsg, sizeof(uimsg),
1977- "Format error in Certificate's notAfter field");
2035+ _T("Format error in Certificate's notAfter field"));
19782036 break;
19792037 case IDS_ERROR_IN_CRL_LAST_UPDATE_FIELD:
19802038 UTIL_get_lang_msg("MSG_ERROR_IN_CRL_LAST_UPDATE_FIELD", uimsg, sizeof(uimsg),
1981- "Format error in CRL's lastUpdate field");
2039+ _T("Format error in CRL's lastUpdate field"));
19822040 break;
19832041 case IDS_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
19842042 UTIL_get_lang_msg("MSG_ERROR_IN_CRL_NEXT_UPDATE_FIELD", uimsg, sizeof(uimsg),
1985- "Format error in CRL's nextUpdate field");
2043+ _T("Format error in CRL's nextUpdate field"));
19862044 break;
19872045 case IDS_OUT_OF_MEM:
19882046 UTIL_get_lang_msg("MSG_OUT_OF_MEM", uimsg, sizeof(uimsg),
1989- "Out of memory");
2047+ _T("Out of memory"));
19902048 break;
19912049 case IDS_DEPTH_ZERO_SELF_SIGNED_CERT:
19922050 UTIL_get_lang_msg("MSG_DEPTH_ZERO_SELF_SIGNED_CERT", uimsg, sizeof(uimsg),
1993- "Self-signed Certificate");
2051+ _T("Self-signed Certificate"));
19942052 break;
19952053 case IDS_SELF_SIGNED_CERT_IN_CHAIN:
19962054 UTIL_get_lang_msg("MSG_SELF_SIGNED_CERT_IN_CHAIN", uimsg, sizeof(uimsg),
1997- "Self-signed Certificate found in Certificate chain");
2055+ _T("Self-signed Certificate found in Certificate chain"));
19982056 break;
19992057 case IDS_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
20002058 UTIL_get_lang_msg("MSG_UNABLE_TO_GET_ISSUER_CERT_LOCALLY", uimsg, sizeof(uimsg),
2001- "Unable to get Local Issuer Certificate");
2059+ _T("Unable to get Local Issuer Certificate"));
20022060 break;
20032061 case IDS_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
20042062 UTIL_get_lang_msg("MSG_UNABLE_TO_VERIFY_LEAF_SIGNATURE", uimsg, sizeof(uimsg),
2005- "Unable to verify the first Certificate");
2063+ _T("Unable to verify the first Certificate"));
20062064 break;
20072065 case IDS_CERT_CHAIN_TOO_LONG:
20082066 UTIL_get_lang_msg("MSG_CERT_CHAIN_TOO_LONG", uimsg, sizeof(uimsg),
2009- "Certificate chain too long");
2067+ _T("Certificate chain too long"));
20102068 break;
20112069 case IDS_CERT_REVOKED:
20122070 UTIL_get_lang_msg("MSG_CERT_REVOKED", uimsg, sizeof(uimsg),
2013- "Certificate revoked");
2071+ _T("Certificate revoked"));
20142072 break;
20152073 case IDS_INVALID_CA:
20162074 UTIL_get_lang_msg("MSG_INVALID_CA", uimsg, sizeof(uimsg),
2017- "Invalid CA Certificate");
2075+ _T("Invalid CA Certificate"));
20182076 break;
20192077 case IDS_PATH_LENGTH_EXCEEDED:
20202078 UTIL_get_lang_msg("MSG_PATH_LENGTH_EXCEEDED", uimsg, sizeof(uimsg),
2021- "Path length constraint exceeded");
2079+ _T("Path length constraint exceeded"));
20222080 break;
20232081 case IDS_INVALID_PURPOSE:
20242082 UTIL_get_lang_msg("MSG_INVALID_PURPOSE", uimsg, sizeof(uimsg),
2025- "Unsupported Certificate purpose");
2083+ _T("Unsupported Certificate purpose"));
20262084 break;
20272085 case IDS_CERT_UNTRUSTED:
20282086 UTIL_get_lang_msg("MSG_CERT_UNTRUSTED", uimsg, sizeof(uimsg),
2029- "Certificate not trusted");
2087+ _T("Certificate not trusted"));
20302088 break;
20312089 case IDS_CERT_REJECTED:
20322090 UTIL_get_lang_msg("MSG_CERT_REJECTED", uimsg, sizeof(uimsg),
2033- "Certificate rejected");
2091+ _T("Certificate rejected"));
20342092 break;
20352093 case IDS_SUBJECT_ISSUER_MISMATCH:
20362094 UTIL_get_lang_msg("MSG_SUBJECT_ISSUER_MISMATCH", uimsg, sizeof(uimsg),
2037- "Subject Issuer mismatch");
2095+ _T("Subject Issuer mismatch"));
20382096 break;
20392097 case IDS_AKID_SKID_MISMATCH:
20402098 UTIL_get_lang_msg("MSG_AKID_SKID_MISMATCH", uimsg, sizeof(uimsg),
2041- "Authority and Subject Key Identifier mismatch");
2099+ _T("Authority and Subject Key Identifier mismatch"));
20422100 break;
20432101 case IDS_AKID_ISSUER_SERIAL_MISMATCH:
20442102 UTIL_get_lang_msg("MSG_AKID_ISSUER_SERIAL_MISMATCH", uimsg, sizeof(uimsg),
2045- "Authority and Issuer Serial Number mismatch");
2103+ _T("Authority and Issuer Serial Number mismatch"));
20462104 break;
20472105 case IDS_KEYUSAGE_NO_CERTSIGN:
20482106 UTIL_get_lang_msg("MSG_KEYUSAGE_NO_CERTSIGN", uimsg, sizeof(uimsg),
2049- "Key usage does not include Certificate signing");
2107+ _T("Key usage does not include Certificate signing"));
20502108 break;
20512109 case IDS_APPLICATION_VERIFICATION:
20522110 UTIL_get_lang_msg("MSG_APPLICATION_VERIFICATION", uimsg, sizeof(uimsg),
2053- "Application verification failure");
2111+ _T("Application verification failure"));
20542112 break;
20552113 case IDS_UNMATCH_COMMON_NAME:
20562114 UTIL_get_lang_msg("MSG_UNMATCH_COMMON_NAME", uimsg, sizeof(uimsg),
2057- "Unmatch Common Name");
2115+ _T("Unmatch Common Name"));
20582116 break;
20592117 case IDS_UNABLE_TO_GET_COMMON_NAME:
20602118 UTIL_get_lang_msg("MSG_UNABLE_TO_GET_COMMON_NAME", uimsg, sizeof(uimsg),
2061- "Unable to get Common Name");
2119+ _T("Unable to get Common Name"));
20622120 break;
20632121 default:
20642122 uimsg[0] = NULL;
@@ -2073,10 +2131,10 @@
20732131 }
20742132
20752133 DECLARE_HOOKAPI(struct hostent*, gethostbyname, (const char* hostname), (hostname)) {
2076- ConnectionInfo* info = connectioninfolist.find(hostname);
2134+ ConnectionInfo* info = connectioninfolist.find((tc)hostname);
20772135 if (info != NULL) {
20782136 if (info->proxy.type == ProxyInfo::TYPE_NONE_FORCE) {
2079- hostname = info->realhost;
2137+ hostname = (u8)info->realhost;
20802138 }else{
20812139 if (info->proxy.type == ProxyInfo::TYPE_SSL
20822140 || info->proxy.type == ProxyInfo::TYPE_HTTP_SSL
@@ -2089,7 +2147,8 @@
20892147 }
20902148 }
20912149 if (info->buffer == NULL) {
2092- int bufferLength = sizeof (DUMMYHOSTENT) + strlen(info->realhost);
2150+ u8 realhostU8 = (const TCHAR *)info->realhost;
2151+ int bufferLength = sizeof (DUMMYHOSTENT) + strlen(realhostU8);
20932152 info->buffer = new char[bufferLength];
20942153 info->fillBuffer(info->buffer, bufferLength);
20952154 }
@@ -2100,7 +2159,7 @@
21002159 }
21012160
21022161 DECLARE_HOOKAPI(HANDLE, WSAAsyncGetHostByName, (HWND window, UINT message, const char* hostname, char* buffer, int bufferLength), (window, message, hostname, buffer, bufferLength)) {
2103- ConnectionInfo* info = connectioninfolist.find(hostname);
2162+ ConnectionInfo* info = connectioninfolist.find((tc)hostname);
21042163 if (info == NULL || info->proxy.type == ProxyInfo::TYPE_NONE_FORCE) {
21052164 return ORIG_WSAAsyncGetHostByName(window, message, hostname, buffer, bufferLength);
21062165 }
@@ -2115,7 +2174,8 @@
21152174 }
21162175 }
21172176 HANDLE handle = connectioninfolist.getTask(info);
2118- int len = sizeof (DUMMYHOSTENT) + strlen(hostname);
2177+ u8 hostnameU8 = hostname;
2178+ int len = sizeof (DUMMYHOSTENT) + strlen(hostnameU8);
21192179 if (bufferLength < len) {
21202180 ::PostMessage(window, message, (WPARAM) handle, MAKELPARAM(len, WSAENOBUFS));
21212181 ::WSASetLastError(WSAENOBUFS);
@@ -2127,7 +2187,7 @@
21272187 }
21282188
21292189 DECLARE_HOOKAPI(HANDLE, WSAAsyncGetAddrInfo, (HWND window, UINT message, const char* hostname, const char* portname, struct addrinfo* hints, struct addrinfo** res), (window, message, hostname, portname, hints, res)) {
2130- ConnectionInfo* info = connectioninfolist.find(hostname);
2190+ ConnectionInfo* info = connectioninfolist.find((tc)hostname);
21312191 if (info == NULL || info->proxy.type == ProxyInfo::TYPE_NONE_FORCE) {
21322192 return ORIG_WSAAsyncGetAddrInfo(window, message, hostname, portname, hints, res);
21332193 }
@@ -2142,7 +2202,8 @@
21422202 }
21432203 }
21442204 HANDLE handle = connectioninfolist.getTask(info);
2145- int bufferLength = sizeof (DUMMYHOSTENT) + strlen(hostname) + 1;
2205+ u8 hostnameU8 = hostname;
2206+ int bufferLength = sizeof (DUMMYHOSTENT) + strlen(hostnameU8) + 1;
21462207 info->buffer = new char[bufferLength];
21472208 info->fillBuffer(info->buffer, bufferLength, portname, hints->ai_family);
21482209 DUMMYHOSTENT* d = (DUMMYHOSTENT*)info->buffer;
@@ -2225,7 +2286,7 @@
22252286 int aicount;
22262287
22272288 ProxyWSockHook():shower(NULL), owner(NULL), resource_module(GetInstanceHandle()), timeout(0), aicount(0) {
2228- HMODULE ws2_32 = ::GetModuleHandle("ws2_32.dll");
2289+ HMODULE ws2_32 = ::GetModuleHandle(_T("ws2_32.dll"));
22292290 LOADAPI(connect)
22302291 LOADAPI(gethostbyname)
22312292 LOADAPI(WSAAsyncGetHostByName)
@@ -2245,54 +2306,54 @@
22452306 }
22462307 void _load(IniFile& ini) {
22472308 String temp;
2248- temp = ini.getString("ProxyType");
2309+ temp = ini.getString(_T("ProxyType"));
22492310 if (temp != NULL) {
22502311 defaultProxy.type = ProxyInfo::parseType(temp);
22512312 if (defaultProxy.type != ProxyInfo::TYPE_NONE) {
2252- defaultProxy.host = ini.getString("ProxyHost");
2313+ defaultProxy.host = ini.getString(_T("ProxyHost"));
22532314 if (defaultProxy.host == NULL || defaultProxy.type == ProxyInfo::TYPE_NONE_FORCE) {
22542315 defaultProxy.type = ProxyInfo::TYPE_NONE;
22552316 }else{
2256- defaultProxy.port = (unsigned short) ini.getInteger("ProxyPort");
2257- defaultProxy.user = ini.getString("ProxyUser");
2317+ defaultProxy.port = (unsigned short) ini.getInteger(_T("ProxyPort"));
2318+ defaultProxy.user = ini.getString(_T("ProxyUser"));
22582319 if (defaultProxy.user != NULL)
2259- defaultProxy.pass = ini.getString("ProxyPass");
2320+ defaultProxy.pass = ini.getString(_T("ProxyPass"));
22602321 }
22612322 }
22622323 }
22632324
2264- timeout = ini.getInteger("ConnectionTimeout", 10);
2325+ timeout = ini.getInteger(_T("ConnectionTimeout"), 10);
22652326
2266- temp = ini.getString("SocksResolve");
2267- if (temp.equalsIgnoreCase("remote")) {
2327+ temp = ini.getString(_T("SocksResolve"));
2328+ if (temp.equalsIgnoreCase(_T("remote"))) {
22682329 resolve = RESOLVE_REMOTE;
2269- }else if (temp.equalsIgnoreCase("local")) {
2330+ }else if (temp.equalsIgnoreCase(_T("local"))) {
22702331 resolve = RESOLVE_LOCAL;
22712332 }else{
22722333 resolve = RESOLVE_AUTO;
22732334 }
22742335
2275- prompt_table[0] = ini.getString("TelnetHostnamePrompt", ">> Host name: ");
2276- prompt_table[1] = ini.getString("TelnetUsernamePrompt", "Username:");
2277- prompt_table[2] = ini.getString("TelnetPasswordPrompt", "Password:");
2278- prompt_table[3] = ini.getString("TelnetConnectedMessage", "-- Connected to ");
2279- prompt_table[4] = ini.getString("TelnetErrorMessage", "!!!!!!!!");
2336+ prompt_table[0] = ini.getString(_T("TelnetHostnamePrompt"), _T(">> Host name: "));
2337+ prompt_table[1] = ini.getString(_T("TelnetUsernamePrompt"), _T("Username:"));
2338+ prompt_table[2] = ini.getString(_T("TelnetPasswordPrompt"), _T("Password:"));
2339+ prompt_table[3] = ini.getString(_T("TelnetConnectedMessage"), _T("-- Connected to "));
2340+ prompt_table[4] = ini.getString(_T("TelnetErrorMessage"), _T("!!!!!!!!"));
22802341
2281- logfile = ini.getString("DebugLog");
2342+ logfile = ini.getString(_T("DebugLog"));
22822343 Logger::open(logfile);
22832344 }
22842345 void _save(IniFile& ini) {
2285- const char* type = NULL;
2286- const char* host = NULL;
2287- const char* port = NULL;
2288- const char* user = NULL;
2289- const char* pass = NULL;
2346+ const TCHAR* type = NULL;
2347+ const TCHAR* host = NULL;
2348+ const TCHAR* port = NULL;
2349+ const TCHAR* user = NULL;
2350+ const TCHAR* pass = NULL;
22902351 if (defaultProxy.type != ProxyInfo::TYPE_NONE && defaultProxy.type != ProxyInfo::TYPE_NONE_FORCE && defaultProxy.host != NULL) {
22912352 type = ProxyInfo::getTypeName(defaultProxy.type);
22922353 host = defaultProxy.host;
22932354 if (defaultProxy.port != 0) {
2294- char* buffer = (char*) alloca(6);
2295- _itoa_s(defaultProxy.port, buffer, 6, 10);
2355+ TCHAR* buffer = (TCHAR*) alloca(sizeof(TCHAR) * 6);
2356+ _itot_s(defaultProxy.port, buffer, 6, 10);
22962357 port = buffer;
22972358 }
22982359 if (defaultProxy.user != NULL) {
@@ -2302,34 +2363,34 @@
23022363 }
23032364 }
23042365 }
2305- ini.setString("ProxyType", type);
2306- ini.setString("ProxyHost", host);
2307- ini.setString("ProxyPort", port);
2308- ini.setString("ProxyUser", user);
2309- ini.setString("ProxyPass", pass);
2366+ ini.setString(_T("ProxyType"), type);
2367+ ini.setString(_T("ProxyHost"), host);
2368+ ini.setString(_T("ProxyPort"), port);
2369+ ini.setString(_T("ProxyUser"), user);
2370+ ini.setString(_T("ProxyPass"), pass);
23102371
2311- ini.setInteger("ConnectionTimeout", timeout);
2372+ ini.setInteger(_T("ConnectionTimeout"), timeout);
23122373
23132374 switch (resolve) {
23142375 case RESOLVE_REMOTE:
2315- type = "remote";
2376+ type = _T("remote");
23162377 break;
23172378 case RESOLVE_LOCAL:
2318- type = "local";
2379+ type = _T("local");
23192380 break;
23202381 default:
2321- type = "auto";
2382+ type = _T("auto");
23222383 break;
23232384 }
2324- ini.setString("SocksResolve", type);
2385+ ini.setString(_T("SocksResolve"), type);
23252386
2326- ini.setString("TelnetHostnamePrompt", prompt_table[0]);
2327- ini.setString("TelnetUsernamePrompt", prompt_table[1]);
2328- ini.setString("TelnetPasswordPrompt", prompt_table[2]);
2329- ini.setString("TelnetConnectedMessage", prompt_table[3]);
2330- ini.setString("TelnetErrorMessage", prompt_table[4]);
2387+ ini.setString(_T("TelnetHostnamePrompt"), prompt_table[0]);
2388+ ini.setString(_T("TelnetUsernamePrompt"), prompt_table[1]);
2389+ ini.setString(_T("TelnetPasswordPrompt"), prompt_table[2]);
2390+ ini.setString(_T("TelnetConnectedMessage"), prompt_table[3]);
2391+ ini.setString(_T("TelnetErrorMessage"), prompt_table[4]);
23312392
2332- ini.setString("DebugLog", logfile);
2393+ ini.setString(_T("DebugLog"), logfile);
23332394 }
23342395 public:
23352396 static void setOwner(HWND owner) {
@@ -2408,11 +2469,11 @@
24082469 static String generateURL() {
24092470 return instance().defaultProxy.generateURL();
24102471 }
2411- static String parseURL(const char* url, BOOL prefix) {
2472+ static String parseURL(const char* url, BOOL prefix) {
24122473 ProxyInfo proxy;
2413- String realhost = ProxyInfo::parse(url, proxy);
2474+ String realhost = ProxyInfo::parse((tc)url, proxy);
24142475 if (realhost != NULL) {
2415- if (realhost.indexOf("://") != -1 && !prefix) {
2476+ if (realhost.indexOf(_T("://")) != -1 && !prefix) {
24162477 proxy.type = proxy.TYPE_NONE;
24172478 }
24182479 if (realhost.length() == 0) {
--- branches/cmake/TTProxy/SSLLIB.h (revision 7326)
+++ branches/cmake/TTProxy/SSLLIB.h (revision 7327)
@@ -11,7 +11,7 @@
1111 rettype apiname arglist { \
1212 static rettype (*func) arglist = \
1313 (rettype (*) arglist) \
14- GetProcAddress(GetModuleHandle(#module), #apiname); \
14+ GetProcAddress(GetModuleHandleA(#module), #apiname); \
1515 return (*func) args; \
1616 }
1717 #define DECLARE_MODULE_API_v(module, apiname, arglist, args) \
@@ -18,7 +18,7 @@
1818 void apiname arglist { \
1919 static void (*func) arglist = \
2020 (void (*) arglist) \
21- GetProcAddress(GetModuleHandle(#module), #apiname); \
21+ GetProcAddress(GetModuleHandleA(#module), #apiname); \
2222 (*func) args; \
2323 }
2424
--- branches/cmake/TTProxy/SSLSocket.h (revision 7326)
+++ branches/cmake/TTProxy/SSLSocket.h (revision 7327)
@@ -84,8 +84,8 @@
8484 }
8585 public:
8686 static bool init() {
87- LIBEAY32() = ::LoadLibrary("LIBEAY32");
88- SSLEAY32() = ::LoadLibrary("SSLEAY32");
87+ LIBEAY32() = ::LoadLibraryA("LIBEAY32");
88+ SSLEAY32() = ::LoadLibraryA("SSLEAY32");
8989 if (LIBEAY32() == NULL || SSLEAY32() == NULL) {
9090 if (LIBEAY32() != NULL) {
9191 ::FreeLibrary(LIBEAY32());
@@ -140,12 +140,15 @@
140140 if (*s2 != '.')
141141 return false;
142142 }else{
143+#if !defined(UNICODE)
143144 if (::IsDBCSLeadByte(*s1)) {
144145 if (*s1 != *s2 || s1 + 1 >= s1_end || s2 + 1 >= s2_end || *(s1 + 1) != *(s2 + 1))
145146 return false;
146147 s1++;
147148 s2++;
148- }else{
149+ } else
150+#endif
151+ {
149152 if (toLowerCase(*s1) != toLowerCase(*s2))
150153 return false;
151154 }
@@ -156,13 +159,15 @@
156159 return true;
157160 }
158161
162+#if 0
159163 static int print_debugw32(const char *str, size_t len, void *u) {
160164 char* buf = (char*) alloca(len + 1);
161165 memcpy(buf, str, len);
162166 buf[len] = '\0';
163- OutputDebugString(buf);
167+ OutputDebugStringA(buf);
164168 return len;
165169 }
170+#endif
166171 private:
167172 SSL* ssl;
168173 long verify_result;
--- branches/cmake/TTProxy/TTProxy.cpp (revision 7326)
+++ branches/cmake/TTProxy/TTProxy.cpp (revision 7327)
@@ -1,7 +1,7 @@
11 // ttx.cpp : DLL アプリケーション用のエントリ ポイントを定義します。
22 //
33
4-#include "stdafx.h"
4+#include "StdAfx.h"
55
66 #include "resource.h"
77
@@ -18,6 +18,7 @@
1818 }
1919
2020 extern "C" __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
21+ (void)reserved;
2122 switch (reason) {
2223 case DLL_PROCESS_ATTACH:
2324 myInstance = instance;
--- branches/cmake/TTProxy/TTProxy.h (revision 7326)
+++ branches/cmake/TTProxy/TTProxy.h (revision 7327)
@@ -1,6 +1,8 @@
11 #ifndef _YEBISOCKS_TTX_H_
22 #define _YEBISOCKS_TTX_H_
33
4+#include "codeconv.h"
5+
46 #include <YCL/DynamicLinkLibrary.h>
57 using namespace yebisuya;
68
@@ -31,7 +33,7 @@
3133 private:
3234 class Shower : public ProxyWSockHook::MessageShower {
3335 public:
34- virtual void showMessage(const char* message)const {
36+ virtual void showMessage(const TCHAR* message)const {
3537 add_error_message(message);
3638 }
3739 } shower;
@@ -46,10 +48,10 @@
4648 PWriteIniFile ORIG_WriteIniFile;
4749 PParseParam ORIG_ParseParam;
4850
49- static void add_error_message(const char* message) {
51+ static void add_error_message(const TCHAR* message) {
5052 if (getInstance().error_message != NULL) {
51- StringBuffer buffer = (const char *)getInstance().error_message;
52- buffer.append("\n\n");
53+ StringBuffer buffer = (const TCHAR *)getInstance().error_message;
54+ buffer.append(_T("\n\n"));
5355 buffer.append(message);
5456 getInstance().error_message = buffer.toString();
5557 }else{
@@ -58,22 +60,22 @@
5860 ::PostMessage(getInstance().cv->HWin, WM_COMMAND, ID_ASYNCMESSAGEBOX, 0);
5961 }
6062 static void read_options(const char* filename) {
61- IniFile inifile(filename, "TTProxy");
63+ IniFile inifile(String((tc)filename), _T("TTProxy"));
6264 ProxyWSockHook::load(inifile);
6365 getInstance().initialized = true;
6466 }
6567 static void write_options(const char* filename) {
66- IniFile inifile(filename, "TTProxy");
68+ IniFile inifile(String((tc)filename), _T("TTProxy"));
6769 ProxyWSockHook::save(inifile);
6870 }
69- static String get_teraterm_dir_relative_name(char* basename) {
71+ static String get_teraterm_dir_relative_name(TCHAR* basename) {
7072 if (basename[0] == '\\' || basename[0] == '/' || basename[0] != '\0' && basename[1] == ':') {
7173 return basename;
7274 }
73- char buf[1024];
75+ TCHAR buf[1024];
7476 ::GetModuleFileName(NULL, buf, sizeof buf);
75- char* filename = NULL;
76- for (char* dst = buf; *dst != '\0'; dst++) {
77+ TCHAR* filename = NULL;
78+ for (TCHAR* dst = buf; *dst != '\0'; dst++) {
7779 if (*dst == '\\' || *dst == '/' || *dst == ':') {
7880 filename = dst + 1;
7981 }
@@ -87,16 +89,16 @@
8789 return buffer.toString();
8890 }
8991
90- static void PASCAL TTXReadINIFile(PCHAR fileName, PTTSet ts) {
92+ static void WINAPI TTXReadINIFile(char *fileName, PTTSet ts) {
9193 getInstance().ORIG_ReadIniFile(fileName, ts);
9294 read_options(fileName);
9395 }
94- static void PASCAL TTXWriteINIFile(PCHAR fileName, PTTSet ts) {
96+ static void WINAPI TTXWriteINIFile(char *fileName, PTTSet ts) {
9597 getInstance().ORIG_WriteIniFile(fileName, ts);
9698 write_options(fileName);
9799 }
98100
99- static void PASCAL TTXParseParam(PCHAR param, PTTSet ts, PCHAR DDETopic) {
101+ static void WINAPI TTXParseParam(PCHAR param, PTTSet ts, PCHAR DDETopic) {
100102 //int param_len=strlen(param);
101103 char option[1024];
102104 int opt_len = sizeof(option);
@@ -115,7 +117,7 @@
115117
116118 if ((option[0] == '-' || option[0] == '/')) {
117119 if ((option[1] == 'F' || option[1] == 'f') && option[2] == '=') {
118- read_options(get_teraterm_dir_relative_name(option + 3));
120+ read_options((u8)get_teraterm_dir_relative_name((TCHAR *)(const TCHAR *)(tc)(option + 3)));
119121 }
120122 }
121123
@@ -156,7 +158,7 @@
156158 String realhost = ProxyWSockHook::parseURL(option, FALSE);
157159 if (realhost != NULL) {
158160 getInstance().realhost = realhost;
159- if (realhost.indexOf("://") == -1) {
161+ if (realhost.indexOf(_T("://")) == -1) {
160162 action = OPTION_CLEAR;
161163 }
162164 else {
@@ -182,7 +184,7 @@
182184
183185 getInstance().ORIG_ParseParam(param, ts, DDETopic);
184186 if (getInstance().ts->HostName[0] == '\0' && getInstance().realhost != NULL) {
185- strcpy_s(getInstance().ts->HostName, sizeof getInstance().ts->HostName, getInstance().realhost);
187+ strcpy_s(getInstance().ts->HostName, sizeof getInstance().ts->HostName, (u8)getInstance().realhost);
186188 }
187189 }
188190
@@ -195,7 +197,7 @@
195197 *((WORD*) lParam) = langid;
196198 return FALSE;
197199 }
198- static void PASCAL TTXInit(PTTSet ts, PComVar cv) {
200+ static void WINAPI TTXInit(PTTSet ts, PComVar cv) {
199201 getInstance().ts = ts;
200202 getInstance().cv = cv;
201203
@@ -202,7 +204,7 @@
202204 ProxyWSockHook::setMessageShower(&getInstance().shower);
203205 }
204206
205- static void PASCAL TTXGetSetupHooks(TTXSetupHooks* hooks) {
207+ static void WINAPI TTXGetSetupHooks(TTXSetupHooks* hooks) {
206208 getInstance().ORIG_ReadIniFile = *hooks->ReadIniFile;
207209 getInstance().ORIG_WriteIniFile = *hooks->WriteIniFile;
208210 getInstance().ORIG_ParseParam = *hooks->ParseParam;
@@ -212,7 +214,7 @@
212214 copy_UILanguageFile();
213215 }
214216
215- static void PASCAL TTXOpenTCP(TTXSockHooks* hooks) {
217+ static void WINAPI TTXOpenTCP(TTXSockHooks* hooks) {
216218 if (!getInstance().initialized) {
217219 read_options(getInstance().ts->SetupFName);
218220 }
@@ -224,7 +226,7 @@
224226 (FARPROC&) *hooks->PWSACancelAsyncRequest = ProxyWSockHook::hook_WSACancelAsyncRequest((FARPROC) *hooks->PWSACancelAsyncRequest);
225227 }
226228
227- static void PASCAL TTXCloseTCP(TTXSockHooks* hooks) {
229+ static void WINAPI TTXCloseTCP(TTXSockHooks* hooks) {
228230 // unhook functions
229231 ProxyWSockHook::unhook_connect((FARPROC) *hooks->Pconnect);
230232 ProxyWSockHook::unhook_WSAAsyncGetHostByName((FARPROC) *hooks->PWSAAsyncGetHostByName);
@@ -234,18 +236,18 @@
234236 ProxyWSockHook::unhook_WSACancelAsyncRequest((FARPROC) *hooks->PWSACancelAsyncRequest);
235237 }
236238
237- static void PASCAL TTXModifyMenu(HMENU menu) {
238- char uimsg[MAX_UIMSG];
239+ static void WINAPI TTXModifyMenu(HMENU menu) {
240+ TCHAR uimsg[MAX_UIMSG];
239241 copy_UILanguageFile();
240242 /* inserts before ID_HELP_ABOUT */
241- UTIL_get_lang_msg("MENU_ABOUT", uimsg, sizeof(uimsg), "About TT&Proxy...");
243+ UTIL_get_lang_msg("MENU_ABOUT", uimsg, _countof(uimsg), _T("About TT&Proxy..."));
242244 InsertMenu(menu, 50990, MF_BYCOMMAND | MF_ENABLED, ID_ABOUTMENU, uimsg);
243245 /* inserts before ID_SETUP_TCPIP */
244- UTIL_get_lang_msg("MENU_SETUP", uimsg, sizeof(uimsg), "&Proxy...");
246+ UTIL_get_lang_msg("MENU_SETUP", uimsg, _countof(uimsg), _T("&Proxy..."));
245247 InsertMenu(menu, 50360, MF_BYCOMMAND | MF_ENABLED, ID_PROXYSETUPMENU, uimsg);
246248 }
247249
248- static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) {
250+ static int WINAPI TTXProcessCommand(HWND hWin, WORD cmd) {
249251 switch (cmd) {
250252 case ID_ABOUTMENU:
251253 copy_UILanguageFile();
@@ -260,7 +262,7 @@
260262 String msg = getInstance().error_message;
261263 getInstance().showing_error_message = true;
262264 getInstance().error_message = NULL;
263- ::MessageBox(hWin, msg, "TTProxy", MB_OK | MB_ICONERROR);
265+ ::MessageBox(hWin, msg, _T("TTProxy"), MB_OK | MB_ICONERROR);
264266 getInstance().showing_error_message = false;
265267 if (getInstance().error_message != NULL) {
266268 ::PostMessage(hWin, WM_COMMAND, ID_ASYNCMESSAGEBOX, 0);
@@ -272,19 +274,20 @@
272274 }
273275 }
274276
275- static void PASCAL TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec) {
277+ static void WINAPI TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec) {
276278 String url = ProxyWSockHook::generateURL();
277279 if (url != NULL) {
278- if (strlen(cmd) + 8 + url.length() >= (unsigned) cmdlen)
280+ u8 urlU8 = (const TCHAR *)url;
281+ if (strlen(cmd) + 8 + strlen(urlU8) >= (unsigned) cmdlen)
279282 return;
280283 strcat_s(cmd, cmdlen, " -proxy=");
281- strcat_s(cmd, cmdlen, url);
284+ strcat_s(cmd, cmdlen, urlU8);
282285 }
283286 }
284287
285- static void PASCAL TTXEnd() {
288+ static void WINAPI TTXEnd() {
286289 if (getInstance().error_message != NULL) {
287- ::MessageBox(NULL, getInstance().error_message, "TTProxy", MB_OK | MB_ICONERROR);
290+ ::MessageBox(NULL, getInstance().error_message, _T("TTProxy"), MB_OK | MB_ICONERROR);
288291 getInstance().error_message = NULL;
289292 }
290293 }
--- branches/cmake/TTProxy/YCL/include/YCL/ComboBoxCtrl.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/ComboBoxCtrl.h (revision 7327)
@@ -30,7 +30,7 @@
3030 int resetContent() {
3131 return SendMessage(CB_RESETCONTENT);
3232 }
33- int addString(const char* string) {
33+ int addString(const TCHAR* string) {
3434 return SendMessage(CB_ADDSTRING, 0, (LPARAM) string);
3535 }
3636 int addItemData(long data) {
@@ -48,12 +48,12 @@
4848 int getTextLen(int index)const {
4949 return SendMessage(CB_GETLBTEXTLEN, index);
5050 }
51- int getText(int index, char* buffer)const {
51+ int getText(int index, TCHAR* buffer)const {
5252 return SendMessage(CB_GETLBTEXT, index, (LPARAM) buffer);
5353 }
5454 String getText(int index) {
5555 int length = getTextLen(index);
56- char* buffer = (char*) alloca(length + 1);
56+ TCHAR* buffer = (TCHAR*) alloca(sizeof(TCHAR) * (length + 1));
5757 getText(index, buffer);
5858 return buffer;
5959 }
--- branches/cmake/TTProxy/YCL/include/YCL/Dialog.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/Dialog.h (revision 7327)
@@ -14,6 +14,10 @@
1414 #include <YCL/Window.h>
1515 #include <YCL/Hashtable.h>
1616
17+#include "dlglib.h"
18+
19+#define DIALOGBOX_REPLACE 1
20+
1721 namespace yebisuya {
1822
1923 class Dialog : virtual public Window {
@@ -65,10 +69,10 @@
6569 int value = ::GetDlgItemInt(*this, id, &succeeded, valueSigned);
6670 return succeeded ? value : defaultValue;
6771 }
68- bool SetDlgItemText(int id, const char* text) {
72+ bool SetDlgItemText(int id, const TCHAR* text) {
6973 return ::SetDlgItemText(*this, id, text) != FALSE;
7074 }
71- int GetDlgItemText(int id, char* buffer, size_t length)const {
75+ int GetDlgItemText(int id, TCHAR* buffer, size_t length)const {
7276 return ::GetDlgItemText(*this, id, buffer, length);
7377 }
7478 String GetDlgItemText(int id)const {
@@ -78,7 +82,11 @@
7882 return ::SendDlgItemMessage(*this, id, message, wparam, lparam);
7983 }
8084 bool EndDialog(int result) {
85+#if defined(DIALOGBOX_REPLACE)
86+ return ::TTEndDialog(*this, result) != FALSE;
87+#else
8188 return ::EndDialog(*this, result) != FALSE;
89+#endif
8290 }
8391 bool MapDialogRect(RECT& rect)const {
8492 return ::MapDialogRect(*this, &rect) != FALSE;
@@ -109,7 +117,11 @@
109117 }
110118 int open(HINSTANCE instance, int resourceId, HWND owner = NULL) {
111119 YCLVERIFY(prepareOpen(this) == NULL, "Another dialog has been opening yet.");
120+#if defined(DIALOGBOX_REPLACE)
121+ return ::TTDialogBoxParam(instance, MAKEINTRESOURCE(resourceId), owner, (DLGPROC)DialogProc, NULL);
122+#else
112123 return ::DialogBoxParam(instance, MAKEINTRESOURCE(resourceId), owner, (DLGPROC)DialogProc, NULL);
124+#endif
113125 }
114126 protected:
115127 virtual bool dispatch(int message, int wparam, long lparam) {
--- branches/cmake/TTProxy/YCL/include/YCL/EditBoxCtrl.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/EditBoxCtrl.h (revision 7327)
@@ -21,13 +21,13 @@
2121 int getLineCount()const {
2222 return SendMessage(EM_GETLINECOUNT);
2323 }
24- int getLine(int line, char* buffer, int length)const {
24+ int getLine(int line, TCHAR* buffer, int length)const {
2525 *((int*) buffer) = length;
2626 return SendMessage(EM_GETLINE, line, (LPARAM) buffer);
2727 }
2828 String getLine(int line)const {
2929 int length = lineLength(line);
30- char* buffer = (char*) alloca(length + 1);
30+ TCHAR* buffer = (TCHAR*) alloca(sizeof(TCHAR) * (length + 1));
3131 getLine(line, buffer, length + 1);
3232 return buffer;
3333 }
--- branches/cmake/TTProxy/YCL/include/YCL/FileVersion.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/FileVersion.h (revision 7327)
@@ -19,84 +19,84 @@
1919
2020 class FileVersion {
2121 private:
22- static const char* ROOT() {
23- static const char string[] = "\\";
24- return string;
25- }
26- static const char* TRANS() {
27- static const char string[] = "\\VarFileInfo\\Translation";
28- return string;
29- }
30- static const char* STRINGBLOCK() {
31- static const char string[] = "\\StringFileInfo\\%08X\\%s";
32- return string;
33- }
22+ static const TCHAR* ROOT() {
23+ static const TCHAR string[] = _T("\\");
24+ return string;
25+ }
26+ static const TCHAR* TRANS() {
27+ static const TCHAR string[] = _T("\\VarFileInfo\\Translation");
28+ return string;
29+ }
30+ static const TCHAR* STRINGBLOCK() {
31+ static const TCHAR string[] = _T("\\StringFileInfo\\%08X\\%s");
32+ return string;
33+ }
3434
35- static const char* COMMENTS() {
36- static const char string[] = "Comments";
37- return string;
35+ static const TCHAR* COMMENTS() {
36+ static const TCHAR string[] = _T("Comments");
37+ return string;
3838 }
39- static const char* COMPANYNAME() {
40- static const char string[] = "CompanyName";
41- return string;
39+ static const TCHAR* COMPANYNAME() {
40+ static const TCHAR string[] = _T("CompanyName");
41+ return string;
4242 }
43- static const char* FILEDESCRIPTION() {
44- static const char string[] = "FileDescription";
45- return string;
43+ static const TCHAR* FILEDESCRIPTION() {
44+ static const TCHAR string[] = _T("FileDescription");
45+ return string;
4646 }
47- static const char* FILEVERSION() {
48- static const char string[] = "FileVersion";
49- return string;
47+ static const TCHAR* FILEVERSION() {
48+ static const TCHAR string[] = _T("FileVersion");
49+ return string;
5050 }
51- static const char* INTERNALNAME() {
52- static const char string[] = "InternalName";
53- return string;
51+ static const TCHAR* INTERNALNAME() {
52+ static const TCHAR string[] = _T("InternalName");
53+ return string;
5454 }
55- static const char* LEGALCOPYRIGHT() {
56- static const char string[] = "LegalCopyright";
57- return string;
55+ static const TCHAR* LEGALCOPYRIGHT() {
56+ static const TCHAR string[] = _T("LegalCopyright");
57+ return string;
5858 }
59- static const char* LEGALTRADEMARKS() {
60- static const char string[] = "LegalTrademarks";
61- return string;
59+ static const TCHAR* LEGALTRADEMARKS() {
60+ static const TCHAR string[] = _T("LegalTrademarks");
61+ return string;
6262 }
63- static const char* ORIGINALFILENAME() {
64- static const char string[] = "OriginalFilename";
65- return string;
63+ static const TCHAR* ORIGINALFILENAME() {
64+ static const TCHAR string[] = _T("OriginalFilename");
65+ return string;
6666 }
67- static const char* PRIVATEBUILD() {
68- static const char string[] = "PrivateBuild";
69- return string;
67+ static const TCHAR* PRIVATEBUILD() {
68+ static const TCHAR string[] = _T("PrivateBuild");
69+ return string;
7070 }
71- static const char* PRODUCTNAME() {
72- static const char string[] = "ProductName";
73- return string;
71+ static const TCHAR* PRODUCTNAME() {
72+ static const TCHAR string[] = _T("ProductName");
73+ return string;
7474 }
75- static const char* PRODUCTVERSION() {
76- static const char string[] = "ProductVersion";
77- return string;
75+ static const TCHAR* PRODUCTVERSION() {
76+ static const TCHAR string[] = _T("ProductVersion");
77+ return string;
7878 }
79- static const char* SPECIALBUILD() {
80- static const char string[] = "SpecialBuild";
81- return string;
79+ static const TCHAR* SPECIALBUILD() {
80+ static const TCHAR string[] = _T("SpecialBuild");
81+ return string;
8282 }
8383
84- char* info;
84+ TCHAR* info;
8585 mutable LPWORD trans;
8686 mutable UINT transSize;
8787 mutable VS_FIXEDFILEINFO* fixedInfo;
8888
8989 void init(HINSTANCE instance) {
90- char buffer[MAX_PATH];
90+ TCHAR buffer[MAX_PATH];
9191 ::GetModuleFileName(instance, buffer, countof(buffer));
9292 init(buffer);
9393 }
94- void init(const char* filename) {
94+ void init(const TCHAR* filename) {
9595 DWORD handle;
96- DWORD size = ::GetFileVersionInfoSize((char*) filename, &handle);
96+ DWORD size = ::GetFileVersionInfoSize(filename, &handle);
9797 if (size != 0){
98- info = new char[size];
99- if (!::GetFileVersionInfo((char*) filename, handle, size, info)) {
98+ info = new TCHAR[size];
99+ if (!::GetFileVersionInfo(filename, handle, size, info)) {
100100 delete[] info;
101101 info = NULL;
102102 }
@@ -105,7 +105,7 @@
105105 bool validateFixedFileInfo()const {
106106 if (fixedInfo == NULL){
107107 UINT size;
108- if (!::VerQueryValue((void*) (const void*) info, (char*) ROOT(), (LPVOID*) &fixedInfo, &size))
108+ if (!::VerQueryValue((void*) (const void*) info, ROOT(), (LPVOID*) &fixedInfo, &size))
109109 return false;
110110 }
111111 return true;
@@ -112,7 +112,7 @@
112112 }
113113 bool validateTranslation()const {
114114 if (trans == NULL){
115- if (!::VerQueryValue((void*) (const void*) info, (char*) TRANS(), (LPVOID*) &trans, &transSize))
115+ if (!::VerQueryValue((void*) (const void*) info, TRANS(), (LPVOID*) &trans, &transSize))
116116 return false;
117117 }
118118 return true;
@@ -124,7 +124,7 @@
124124 FileVersion(HINSTANCE hInstance):info(NULL), fixedInfo(NULL), trans(NULL), transSize(0) {
125125 init(hInstance);
126126 }
127- FileVersion(const char* filename):info(NULL), fixedInfo(NULL), trans(NULL), transSize(0) {
127+ FileVersion(const TCHAR* filename):info(NULL), fixedInfo(NULL), trans(NULL), transSize(0) {
128128 init(filename);
129129 }
130130 ~FileVersion() {
@@ -152,51 +152,51 @@
152152 int getCharset(int index = 0)const {
153153 return validateTranslation() ? MAKELONG(trans[index * 2 + 1], trans[index * 2]) : 0;
154154 }
155- const char* getString(int charset, const char* blockName)const {
156- char buffer[64];
155+ const TCHAR* getString(int charset, const TCHAR* blockName)const {
156+ TCHAR buffer[64];
157157 wsprintf(buffer, STRINGBLOCK(), charset, blockName);
158158 UINT size;
159- const char* string;
159+ const TCHAR* string;
160160 return ::VerQueryValue((void*) (const void*) info, buffer, (LPVOID*) &string, &size) ? string : NULL;
161161 }
162- const char* getString(const char* blockName)const {
162+ const TCHAR* getString(const TCHAR* blockName)const {
163163 return getString(getCharset(), blockName);
164164 }
165165
166- const char* getComments()const {
166+ const TCHAR* getComments()const {
167167 return getString(COMMENTS());
168168 }
169- const char* getCompanyName()const {
169+ const TCHAR* getCompanyName()const {
170170 return getString(COMPANYNAME());
171171 }
172- const char* getFileDescription()const {
172+ const TCHAR* getFileDescription()const {
173173 return getString(FILEDESCRIPTION());
174174 }
175- const char* getFileVersion()const {
175+ const TCHAR* getFileVersion()const {
176176 return getString(FILEVERSION());
177177 }
178- const char* getInternalName()const {
178+ const TCHAR* getInternalName()const {
179179 return getString(INTERNALNAME());
180180 }
181- const char* getLegalCopyright()const {
181+ const TCHAR* getLegalCopyright()const {
182182 return getString(LEGALCOPYRIGHT());
183183 }
184- const char* getLegalTrademarks()const {
184+ const TCHAR* getLegalTrademarks()const {
185185 return getString(LEGALTRADEMARKS());
186186 }
187- const char* getOriginalFilename()const {
187+ const TCHAR* getOriginalFilename()const {
188188 return getString(ORIGINALFILENAME());
189189 }
190- const char* getPrivateBuild()const {
190+ const TCHAR* getPrivateBuild()const {
191191 return getString(PRIVATEBUILD());
192192 }
193- const char* getProductName()const {
193+ const TCHAR* getProductName()const {
194194 return getString(PRODUCTNAME());
195195 }
196- const char* getProductVersion()const {
196+ const TCHAR* getProductVersion()const {
197197 return getString(PRODUCTVERSION());
198198 }
199- const char* getSpecialBuild()const {
199+ const TCHAR* getSpecialBuild()const {
200200 return getString(SPECIALBUILD());
201201 }
202202
--- branches/cmake/TTProxy/YCL/include/YCL/IniFile.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/IniFile.h (revision 7327)
@@ -24,17 +24,17 @@
2424 class IniFile {
2525 private:
2626 static String YES() {
27- static const char YES[] = "yes";
27+ static const TCHAR YES[] = _T("yes");
2828 static String string = YES;
2929 return string;
3030 }
3131 static String NO() {
32- static const char NO[] = "no";
32+ static const TCHAR NO[] = _T("no");
3333 static String string = NO;
3434 return string;
3535 }
36- static const char* INVALID() {
37- static const char string[] = "\n:";
36+ static const TCHAR* INVALID() {
37+ static const TCHAR string[] = _T("\n:");
3838 return string;
3939 }
4040
@@ -43,16 +43,16 @@
4343 Vector<String> list;
4444 mutable int index;
4545 public:
46- EnumKeyNames(const char* filename, const char* section):index(0) {
46+ EnumKeyNames(const TCHAR* filename, const TCHAR* section):index(0) {
4747 Hashtable<String, int> table;
48- int section_len = strlen(section);
49- char* buffer;
48+ int section_len = _tcslen(section);
49+ TCHAR* buffer;
5050 size_t size = 256;
5151 while ((buffer = getSectionNames(filename, size)) == NULL)
5252 size += 256;
53- const char* name = buffer;
53+ const TCHAR* name = buffer;
5454 while (*name != '\0') {
55- if (strncmp(name, section, section_len) == 0) {
55+ if (_tcsncmp(name, section, section_len) == 0) {
5656 if (name[section_len] == '\\') {
5757 int i;
5858 name += section_len + 1;
@@ -59,8 +59,10 @@
5959 for (i = 0; name[i] != '\0'; i++) {
6060 if (name[i] == '\\')
6161 break;
62+#if !defined(UNICODE)
6263 if (String::isLeadByte(name[i]))
6364 i++;
65+#endif
6466 }
6567 table.put(String(name, i), 1);
6668 }
@@ -84,10 +86,10 @@
8486 friend class EnumKeyNames;
8587 class EnumValueNames : public Enumeration<String> {
8688 private:
87- char* buffer;
88- mutable char* p;
89+ TCHAR* buffer;
90+ mutable TCHAR* p;
8991 public:
90- EnumValueNames(const char* filename, const char* section) {
92+ EnumValueNames(const TCHAR* filename, const TCHAR* section) {
9193 size_t size = 256;
9294 while ((buffer = getValueNames(filename, section, size)) == NULL)
9395 size += 256;
@@ -140,23 +142,23 @@
140142 return ((IniFile*) ini)->deleteValue(name);
141143 }
142144 };
143- static char* getSectionNames(const char* filename, size_t size) {
144- char* buffer = new char[size];
145+ static TCHAR* getSectionNames(const TCHAR* filename, size_t size) {
146+ TCHAR* buffer = new TCHAR[size];
145147 if (::GetPrivateProfileSectionNames(buffer, size, filename) < size - 2)
146148 return buffer;
147149 delete[] buffer;
148150 return NULL;
149151 }
150- static char* getValueNames(const char* filename, const char* section, size_t size) {
151- static const char null = '\0';
152- char* buffer = new char[size];
152+ static TCHAR* getValueNames(const TCHAR* filename, const TCHAR* section, size_t size) {
153+ static const TCHAR null = '\0';
154+ TCHAR* buffer = new TCHAR[size];
153155 if (::GetPrivateProfileString(section, NULL, &null, buffer, size, filename) < size - 2)
154156 return buffer;
155157 delete[] buffer;
156158 return NULL;
157159 }
158- static String getString(const char* filename, const char* section, const char* name, bool& exists, size_t size) {
159- char* buffer = (char*) alloca(size);
160+ static String getString(const TCHAR* filename, const TCHAR* section, const TCHAR* name, bool& exists, size_t size) {
161+ TCHAR* buffer = (TCHAR*) alloca(sizeof(TCHAR) * size);
160162 size_t len = ::GetPrivateProfileString(section, name, INVALID(), buffer, size, filename);
161163 if (len < size - 2) {
162164 // 改行を含んだ文字列はiniファイルからは取得できないので取得失敗したことが分かる
@@ -170,24 +172,24 @@
170172 exists = true;
171173 return NULL;
172174 }
173- static String generateSectionName(const char* parentSection, const char* subkeyName) {
175+ static String generateSectionName(const TCHAR* parentSection, const TCHAR* subkeyName) {
174176 StringBuffer buffer = parentSection;
175177 buffer.append('\\');
176178 buffer.append(subkeyName);
177179 return buffer.toString();
178180 }
179- static bool deleteAllSubsection(const char* filename, const char* section, const char* subkey) {
181+ static bool deleteAllSubsection(const TCHAR* filename, const TCHAR* section, const TCHAR* subkey) {
180182 String keyname = generateSectionName(section, subkey);
181183 int keyname_len = keyname.length();
182184
183- char* buffer;
185+ TCHAR* buffer;
184186 size_t size = 256;
185187 while ((buffer = getSectionNames(filename, size)) == NULL)
186188 size += 256;
187- const char* name = buffer;
189+ const TCHAR* name = buffer;
188190 bool succeeded = true;
189191 while (*name != '\0') {
190- if (strncmp(name, keyname, keyname_len) == 0) {
192+ if (_tcsncmp(name, keyname, keyname_len) == 0) {
191193 if (name[keyname_len] == '\0' || name[keyname_len] == '\\') {
192194 if (!::WritePrivateProfileString(name, NULL, NULL, filename)) {
193195 succeeded = false;
@@ -209,19 +211,19 @@
209211 }
210212 IniFile(String filename, String section):filename(filename), section(section) {
211213 }
212- IniFile(const IniFile& parent, const char* subkeyName):filename(parent.filename), section(generateSectionName(parent.section, subkeyName)) {
214+ IniFile(const IniFile& parent, const TCHAR* subkeyName):filename(parent.filename), section(generateSectionName(parent.section, subkeyName)) {
213215 }
214216
215217 bool isOpened()const {
216218 return filename != NULL && section != NULL;
217219 }
218- long getInteger(const char* name, long defaultValue = 0)const {
220+ long getInteger(const TCHAR* name, long defaultValue = 0)const {
219221 return filename != NULL && section != NULL ? ::GetPrivateProfileInt(section, name, defaultValue, filename) : defaultValue;
220222 }
221- String getString(const char* name)const {
223+ String getString(const TCHAR* name)const {
222224 return getString(name, NULL);
223225 }
224- String getString(const char* name, String defaultValue)const {
226+ String getString(const TCHAR* name, String defaultValue)const {
225227 if (filename != NULL && section != NULL && name != NULL) {
226228 size_t size = 256;
227229 String string;
@@ -233,7 +235,7 @@
233235 }
234236 return defaultValue;
235237 }
236- bool getBoolean(const char* name, bool defaultValue = false)const {
238+ bool getBoolean(const TCHAR* name, bool defaultValue = false)const {
237239 String string = getString(name);
238240 if (string != NULL) {
239241 if (string == YES())
@@ -244,10 +246,10 @@
244246 return defaultValue;
245247 }
246248
247- bool setInteger(const char* name, long value) {
249+ bool setInteger(const TCHAR* name, long value) {
248250 return setString(name, Integer::toString(value));
249251 }
250- bool setString(const char* name, String value) {
252+ bool setString(const TCHAR* name, String value) {
251253 if (filename != NULL && section != NULL && name != NULL) {
252254 // NULLでなければエスケープしてから""で括る
253255 if (value != NULL) {
@@ -262,30 +264,30 @@
262264 }
263265 return false;
264266 }
265- bool setBoolean(const char* name, bool value) {
267+ bool setBoolean(const TCHAR* name, bool value) {
266268 return setString(name, value ? YES() : NO());
267269 }
268270
269- bool existsValue(const char* name) {
270- char buffer[3];
271+ bool existsValue(const TCHAR* name) {
272+ TCHAR buffer[3];
271273 ::GetPrivateProfileString(section, name, INVALID(), buffer, countof(buffer), filename);
272274 return buffer[0] != '\n';
273275 }
274- bool deleteKey(const char* name) {
276+ bool deleteKey(const TCHAR* name) {
275277 return filename != NULL && section != NULL && name != NULL && deleteAllSubsection(filename, section, name);
276278 }
277- bool deleteValue(const char* name) {
279+ bool deleteValue(const TCHAR* name) {
278280 return filename != NULL && section != NULL && name != NULL
279281 && ::WritePrivateProfileString(section, name, NULL, filename) != FALSE;
280282 }
281283
282- bool open(String filename, String section) {
284+ bool open(String _filename, String _section) {
283285 close();
284- this->filename = filename;
285- this->section = section;
286+ filename = _filename;
287+ section = _section;
286288 return isOpened();
287289 }
288- bool open(const IniFile& parent, const char* subkeyName) {
290+ bool open(const IniFile& parent, const TCHAR* subkeyName) {
289291 close();
290292 filename = parent.filename;
291293 section = generateSectionName(parent.section, subkeyName);
--- branches/cmake/TTProxy/YCL/include/YCL/Integer.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/Integer.h (revision 7327)
@@ -46,8 +46,8 @@
4646 static String toString(unsigned long value, int base, bool negative) {
4747 if (base < 2 || base > 36)
4848 return NULL;
49- char buffer[64];
50- char* p = buffer + countof(buffer);
49+ TCHAR buffer[64];
50+ TCHAR* p = buffer + countof(buffer);
5151 *--p = '\0';
5252 if (value == 0) {
5353 *--p = '0';
--- branches/cmake/TTProxy/YCL/include/YCL/Resource.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/Resource.h (revision 7327)
@@ -10,8 +10,8 @@
1010 #endif // _MSC_VER >= 1000
1111
1212 #include <YCL/common.h>
13-
1413 #include <YCL/String.h>
14+#include "codeconv.h"
1515
1616 namespace yebisuya {
1717
@@ -18,7 +18,7 @@
1818 class Resource {
1919 public:
2020 static String loadString(HINSTANCE instance, UINT id, int bufsize) {
21- char* buffer = (char*) alloca(bufsize);
21+ TCHAR* buffer = (TCHAR*) alloca(sizeof(TCHAR) * bufsize);
2222 int length = loadString(instance, id, buffer, bufsize);
2323 if (length >= bufsize - 1)
2424 return NULL;
@@ -28,10 +28,10 @@
2828 }
2929
3030 public:
31- static int loadString(UINT id, char* buffer, int bufsize) {
31+ static int loadString(UINT id, TCHAR* buffer, int bufsize) {
3232 return loadString(GetInstanceHandle(), id, buffer, bufsize);
3333 }
34- static int loadString(HINSTANCE instance, UINT id, char* buffer, int bufsize) {
34+ static int loadString(HINSTANCE instance, UINT id, TCHAR* buffer, int bufsize) {
3535 return LoadString(instance, id, buffer, bufsize);
3636 }
3737 static String loadString(int id) {
@@ -54,10 +54,10 @@
5454 return loadIcon(GetInstanceHandle(), id);
5555 }
5656 static HICON loadIcon(HINSTANCE instance, int id) {
57- return loadIcon(instance, MAKEINTRESOURCE(id));
57+ return loadIcon(instance, MAKEINTRESOURCEA(id));
5858 }
5959 static HICON loadIcon(HINSTANCE instance, const char* id) {
60- return ::LoadIcon(instance, id);
60+ return ::LoadIcon(instance, (tc)id);
6161 }
6262
6363 static HICON loadIcon(int id, int cx, int cy) {
@@ -67,7 +67,7 @@
6767 return loadIcon(GetInstanceHandle(), id, cx, cy);
6868 }
6969 static HICON loadIcon(HINSTANCE instance, int id, int cx, int cy) {
70- return loadIcon(instance, MAKEINTRESOURCE(id), cx, cy);
70+ return loadIcon(instance, MAKEINTRESOURCEA(id), cx, cy);
7171 }
7272 static HICON loadIcon(HINSTANCE instance, const char* id, int cx, int cy) {
7373 return loadIcon(instance, id, cx, cy, LR_DEFAULTCOLOR | LR_SHARED);
@@ -79,10 +79,10 @@
7979 return loadIcon(GetInstanceHandle(), id, cx, cy, flags);
8080 }
8181 static HICON loadIcon(HINSTANCE instance, int id, int cx, int cy, int flags) {
82- return loadIcon(instance, MAKEINTRESOURCE(id), cx, cy, flags);
82+ return loadIcon(instance, MAKEINTRESOURCEA(id), cx, cy, flags);
8383 }
8484 static HICON loadIcon(HINSTANCE instance, const char* id, int cx, int cy, int flags) {
85- return (HICON) ::LoadImage(instance, id, IMAGE_ICON, cx, cy, flags);
85+ return (HICON) ::LoadImage(instance, (tc)id, IMAGE_ICON, cx, cy, flags);
8686 }
8787
8888 static HCURSOR loadCursor(int id) {
@@ -92,10 +92,10 @@
9292 return loadCursor(GetInstanceHandle(), id);
9393 }
9494 static HCURSOR loadCursor(HINSTANCE instance, int id) {
95- return loadCursor(instance, MAKEINTRESOURCE(id));
95+ return loadCursor(instance, MAKEINTRESOURCEA(id));
9696 }
9797 static HCURSOR loadCursor(HINSTANCE instance, const char* id) {
98- return ::LoadCursor(instance, id);
98+ return ::LoadCursor(instance, (tc)id);
9999 }
100100
101101 static HCURSOR loadCursor(int id, int cx, int cy) {
@@ -105,7 +105,7 @@
105105 return loadCursor(GetInstanceHandle(), id, cx, cy);
106106 }
107107 static HCURSOR loadCursor(HINSTANCE instance, int id, int cx, int cy) {
108- return loadCursor(instance, MAKEINTRESOURCE(id), cx, cy);
108+ return loadCursor(instance, MAKEINTRESOURCEA(id), cx, cy);
109109 }
110110 static HCURSOR loadCursor(HINSTANCE instance, const char* id, int cx, int cy) {
111111 return loadCursor(instance, id, cx, cy, LR_DEFAULTCOLOR | LR_SHARED);
@@ -117,10 +117,10 @@
117117 return loadCursor(GetInstanceHandle(), id, cx, cy, flags);
118118 }
119119 static HCURSOR loadCursor(HINSTANCE instance, int id, int cx, int cy, int flags) {
120- return loadCursor(instance, MAKEINTRESOURCE(id), cx, cy, flags);
120+ return loadCursor(instance, MAKEINTRESOURCEA(id), cx, cy, flags);
121121 }
122122 static HCURSOR loadCursor(HINSTANCE instance, const char* id, int cx, int cy, int flags) {
123- return (HCURSOR) ::LoadImage(instance, id, IMAGE_CURSOR, cx, cy, flags);
123+ return (HCURSOR) ::LoadImage(instance, (tc)id, IMAGE_CURSOR, cx, cy, flags);
124124 }
125125
126126 static HMENU loadMenu(int id) {
@@ -130,10 +130,10 @@
130130 return loadMenu(GetInstanceHandle(), id);
131131 }
132132 static HMENU loadMenu(HINSTANCE instance, int id) {
133- return loadMenu(instance, MAKEINTRESOURCE(id));
133+ return loadMenu(instance, MAKEINTRESOURCEA(id));
134134 }
135135 static HMENU loadMenu(HINSTANCE instance, const char* id) {
136- return ::LoadMenu(instance, id);
136+ return ::LoadMenu(instance, (tc)id);
137137 }
138138 };
139139
--- branches/cmake/TTProxy/YCL/include/YCL/String.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/String.h (revision 7327)
@@ -12,6 +12,7 @@
1212 #include <YCL/common.h>
1313
1414 #include <string.h>
15+#include <tchar.h>
1516
1617 namespace yebisuya {
1718
@@ -21,7 +22,7 @@
2122 // 文字列を格納するバッファ。
2223 // 文字列の前には参照カウンタを持ち、
2324 // 代入や破棄の際にはそこを変更する。
24- const char* string;
25+ const TCHAR* string;
2526
2627 // utilities
2728 // 文字列を格納するバッファを作成する。
@@ -31,10 +32,10 @@
3132 // length 文字列の長さ。
3233 // 返値:
3334 // 作成したバッファの文字列部のアドレス。
34- static char* createBuffer(size_t length) {
35- size_t* count = (size_t*) new unsigned char[sizeof (size_t) + sizeof (char) * (length + 1)];
35+ static TCHAR* createBuffer(size_t length) {
36+ size_t* count = (size_t*) new TCHAR[sizeof (size_t) + sizeof (TCHAR) * (length + 1)];
3637 *count = 0;
37- return (char*) (count + 1);
38+ return (TCHAR*) (count + 1);
3839 }
3940 // 文字列を格納したバッファを作成する。
4041 // 引数:
@@ -41,8 +42,8 @@
4142 // source 格納する文字列。
4243 // 返値:
4344 // 作成したバッファの文字列部のアドレス。
44- static const char* create(const char* source) {
45- return source != NULL ? create(source, strlen(source)) : NULL;
45+ static const TCHAR* create(const TCHAR* source) {
46+ return source != NULL ? create(source, _tcslen(source)) : NULL;
4647 }
4748 // 文字列を格納したバッファを作成する。
4849 // 引数:
@@ -50,10 +51,10 @@
5051 // length 文字列の長さ。
5152 // 返値:
5253 // 作成したバッファの文字列部のアドレス。
53- static const char* create(const char* source, size_t length) {
54+ static const TCHAR* create(const TCHAR* source, size_t length) {
5455 if (source != NULL) {
55- char* buffer = createBuffer(length);
56- memcpy(buffer, source, length);
56+ TCHAR* buffer = createBuffer(length);
57+ memcpy(buffer, source, sizeof(TCHAR) * length);
5758 buffer[length] = '\0';
5859 return buffer;
5960 }
@@ -65,12 +66,12 @@
6566 // str2 連結する文字列(後)。
6667 // 返値:
6768 // 作成したバッファの文字列部のアドレス。
68- static const char* concat(const char* str1, const char* str2) {
69- size_t len1 = strlen(str1);
70- size_t len2 = strlen(str2);
71- char* buffer = createBuffer(len1 + len2);
72- memcpy(buffer, str1, len1);
73- memcpy(buffer + len1, str2, len2);
69+ static const TCHAR* concat(const TCHAR* str1, const TCHAR* str2) {
70+ size_t len1 = _tcslen(str1);
71+ size_t len2 = _tcslen(str2);
72+ TCHAR* buffer = createBuffer(len1 + len2);
73+ memcpy(buffer, str1, sizeof(TCHAR) * len1);
74+ memcpy(buffer + len1, str2, sizeof(TCHAR) * len2);
7475 buffer[len1 + len2] = '\0';
7576 return buffer;
7677 }
@@ -80,7 +81,7 @@
8081 if (string != NULL) {
8182 size_t* count = (size_t*) string - 1;
8283 if (--*count == 0)
83- delete[] (unsigned char*) count;
84+ delete[] (TCHAR*) count;
8485 }
8586 }
8687 // 参照カウンタを増やす。
@@ -95,7 +96,7 @@
9596 // 新しいバッファの参照カウンタを増やす。
9697 // 引数:
9798 // source 置き換える新しいバッファ。
98- void set(const char* source) {
99+ void set(const TCHAR* source) {
99100 if (string != source) {
100101 release();
101102 string = source;
@@ -111,7 +112,7 @@
111112 // 元の文字列を指定するコンストラクタ。
112113 // 引数:
113114 // source 元の文字列。
114- String(const char* source):string(NULL) {
115+ String(const TCHAR* source):string(NULL) {
115116 set(create(source));
116117 }
117118 // 元の文字列を長さ付きで指定するコンストラクタ。
@@ -118,7 +119,7 @@
118119 // 引数:
119120 // source 元の文字列。
120121 // length 文字列の長さ。
121- String(const char* source, size_t length):string(NULL) {
122+ String(const TCHAR* source, size_t length):string(NULL) {
122123 set(create(source, length));
123124 }
124125 // コピーコンストラクタ。
@@ -131,7 +132,7 @@
131132 // 引数:
132133 // str1 前になる文字列。
133134 // str2 後になる文字列。
134- String(const char* str1, const char* str2):string(NULL) {
135+ String(const TCHAR* str1, const TCHAR* str2):string(NULL) {
135136 set(concat(str1, str2));
136137 }
137138 // 二つの文字列を連結するコンストラクタ。
@@ -138,7 +139,7 @@
138139 // 引数:
139140 // str1 前になる文字列。
140141 // str2 後になる文字列。
141- String(const String& str1, const char* str2):string(NULL) {
142+ String(const String& str1, const TCHAR* str2):string(NULL) {
142143 set(*str2 != '\0' ? concat(str1.string, str2) : str1.string);
143144 }
144145 // destructor
@@ -153,7 +154,7 @@
153154 // source 連結する文字列。
154155 // 返値:
155156 // 連結された文字列。
156- String concat(const char* source)const {
157+ String concat(const TCHAR* source)const {
157158 return String(*this, source);
158159 }
159160 // 文字列との比較を行う。
@@ -162,12 +163,12 @@
162163 // str 比較する文字列。
163164 // 返値:
164165 // 等しければ0、strの方が大きければ負、小さければ正。
165- int compareTo(const char* str)const {
166+ int compareTo(const TCHAR* str)const {
166167 if (str == NULL)
167168 return string == NULL ? 0 : 1;
168169 else if (string == NULL)
169170 return -1;
170- return strcmp(string, str);
171+ return _tcscmp(string, str);
171172 }
172173 // 文字列との比較を大文字小文字の区別なしで行う。
173174 // NULLとも比較できる。
@@ -175,12 +176,12 @@
175176 // str 比較する文字列。
176177 // 返値:
177178 // 等しければ0、strの方が大きければ負、小さければ正。
178- int compareToIgnoreCase(const char* str)const {
179+ int compareToIgnoreCase(const TCHAR* str)const {
179180 if (str == NULL)
180181 return string == NULL ? 0 : 1;
181182 else if (string == NULL)
182183 return -1;
183- return _stricmp(string, str);
184+ return _tcsicmp(string, str);
184185 }
185186 // 文字列との比較を行う。
186187 // NULLとも比較できる。
@@ -188,7 +189,7 @@
188189 // str 比較する文字列。
189190 // 返値:
190191 // 等しければ真。
191- bool equals(const char* str)const {
192+ bool equals(const TCHAR* str)const {
192193 return compareTo(str) == 0;
193194 }
194195 // 文字列との比較を大文字小文字の区別なしで行う。
@@ -197,7 +198,7 @@
197198 // str 比較する文字列。
198199 // 返値:
199200 // 等しければ真。
200- bool equalsIgnoreCase(const char* str)const {
201+ bool equalsIgnoreCase(const TCHAR* str)const {
201202 return compareToIgnoreCase(str) == 0;
202203 }
203204 // 指定された文字列で始まっているかどうかを判定する。
@@ -205,7 +206,7 @@
205206 // str 比較する文字列。
206207 // 返値:
207208 // 指定された文字列で始まっていれば真。
208- bool startsWith(const char* str)const {
209+ bool startsWith(const TCHAR* str)const {
209210 return startsWith(str, 0);
210211 }
211212 // 指定の位置から指定された文字列で始まっているかどうかを判定する。
@@ -213,8 +214,8 @@
213214 // str 比較する文字列。
214215 // 返値:
215216 // 指定された文字列で始まっていれば真。
216- bool startsWith(const char* str, int offset)const {
217- return strncmp(string, str, strlen(str)) == 0;
217+ bool startsWith(const TCHAR* str, int offset)const {
218+ return _tcsncmp(string, str, _tcslen(str)) == 0;
218219 }
219220 // 指定された文字列で終わっているかどうかを判定する。
220221 // 引数:
@@ -221,13 +222,13 @@
221222 // str 比較する文字列。
222223 // 返値:
223224 // 指定された文字列で終わっていれば真。
224- //
225- bool endsWith(const char* str)const {
226- size_t str_length = strlen(str);
225+ //
226+ bool endsWith(const TCHAR* str)const {
227+ size_t str_length = _tcslen(str);
227228 size_t string_length = length();
228229 if (string_length < str_length)
229230 return false;
230- return strcmp(string + string_length - str_length, str) == 0;
231+ return _tcscmp(string + string_length - str_length, str) == 0;
231232 }
232233 // 指定の文字がどの位置にあるかを探す。
233234 // 引数:
@@ -234,7 +235,7 @@
234235 // chr 探す文字。
235236 // 返値:
236237 // 文字の見つかったインデックス。見つからなければ-1。
237- int indexOf(char chr)const {
238+ int indexOf(TCHAR chr)const {
238239 return indexOf(chr, 0);
239240 }
240241 // 指定の文字がどの位置にあるかを指定の位置から探す。
@@ -243,12 +244,10 @@
243244 // from 探し始める位置。
244245 // 返値:
245246 // 文字の見つかったインデックス。見つからなければ-1。
246- int indexOf(char chr, size_t from)const {
247- if (from < 0)
248- from = 0;
249- else if (from >= length())
247+ int indexOf(TCHAR chr, size_t from)const {
248+ if (from >= length())
250249 return -1;
251- const char* found = strchr(string + from, chr);
250+ const TCHAR* found = _tcschr(string + from, chr);
252251 if (found == NULL)
253252 return -1;
254253 return found - string;
@@ -258,7 +257,7 @@
258257 // str 探す文字列。
259258 // 返値:
260259 // 文字列の見つかったインデックス。見つからなければ-1。
261- int indexOf(const char* str)const {
260+ int indexOf(const TCHAR* str)const {
262261 return indexOf(str, 0);
263262 }
264263 // 指定の文字列がどの位置にあるかを指定の位置から探す。
@@ -267,13 +266,11 @@
267266 // from 探し始める位置。
268267 // 返値:
269268 // 文字列の見つかったインデックス。見つからなければ-1。
270- //
271- int indexOf(const char* str, size_t from)const {
272- if (from < 0)
273- from = 0;
274- else if (from >= length())
269+ //
270+ int indexOf(const TCHAR* str, size_t from)const {
271+ if (from >= length())
275272 return -1;
276- const char* found = strstr(string + from, str);
273+ const TCHAR* found = _tcsstr(string + from, str);
277274 if (found == NULL)
278275 return -1;
279276 return found - string;
@@ -280,7 +277,7 @@
280277 }
281278 // 文字列の長さを返す。
282279 size_t length()const {
283- return strlen(string);
280+ return _tcslen(string);
284281 }
285282 // 指定の文字が最後に見つかる位置を取得する。
286283 // 引数:
@@ -287,7 +284,7 @@
287284 // chr 探す文字。
288285 // 返値:
289286 // 文字の見つかったインデックス。見つからなければ-1。
290- int lastIndexOf(char chr)const {
287+ int lastIndexOf(TCHAR chr)const {
291288 return lastIndexOf(chr, (size_t) -1);
292289 }
293290 // 指定の文字が指定の位置よりも前で最後に見つかる位置を取得する。
@@ -296,18 +293,20 @@
296293 // from 探し始める位置。
297294 // 返値:
298295 // 文字の見つかったインデックス。見つからなければ-1。
299- int lastIndexOf(char chr, size_t from)const {
296+ int lastIndexOf(TCHAR chr, size_t from)const {
300297 size_t len = length();
301298 if (from > len - 1)
302299 from = len - 1;
303- const char* s = string;
304- const char* end = string + from;
305- const char* found = NULL;
300+ const TCHAR* s = string;
301+ const TCHAR* end = string + from;
302+ const TCHAR* found = NULL;
306303 while (*s != '0' && s <= end) {
307304 if (*s == chr)
308305 found = s;
306+#if !defined(UNICODE)
309307 if (isLeadByte(*s))
310308 s++;
309+#endif
311310 s++;
312311 }
313312 return found != NULL ? found - string : -1;
@@ -317,7 +316,7 @@
317316 // str 探す文字列。
318317 // 返値:
319318 // 文字列の見つかったインデックス。見つからなければ-1。
320- int lastIndexOf(const char* str)const {
319+ int lastIndexOf(const TCHAR* str)const {
321320 return lastIndexOf(str, (size_t) -1);
322321 }
323322 // 指定の文字列が指定の位置よりも前で最後に見つかる位置を取得する。
@@ -326,14 +325,14 @@
326325 // from 探し始める位置。
327326 // 返値:
328327 // 文字列の見つかったインデックス。見つからなければ-1。
329- int lastIndexOf(const char* str, size_t from)const {
328+ int lastIndexOf(const TCHAR* str, size_t from)const {
330329 size_t len = length();
331- size_t str_len = strlen(str);
330+ size_t str_len = _tcslen(str);
332331 if (from > len - str_len)
333332 from = len - str_len;
334- const char* s = string + from;
333+ const TCHAR* s = string + from;
335334 while (s >= string) {
336- if (strncmp(s, str, str_len) == 0)
335+ if (_tcsncmp(s, str, str_len) == 0)
337336 return s - string;
338337 s--;
339338 }
@@ -361,8 +360,8 @@
361360 // index 取り出す文字の位置。
362361 // 返値:
363362 // 指定の位置にある文字。
364- char charAt(size_t index)const {
365- return index >= 0 && index < length() ? string[index] : '\0';
363+ TCHAR TCHARAt(size_t index)const {
364+ return index < length() ? string[index] : '\0';
366365 }
367366 // 指定の文字を指定の文字に置き換えます。
368367 // 引数:
@@ -370,13 +369,16 @@
370369 // newChr 置き換える文字。
371370 // 返値:
372371 // 置換後の文字列。
373- String replace(char oldChr, char newChr)const {
372+ String replace(TCHAR oldChr, TCHAR newChr)const {
374373 String result(string);
375- char* s = (char*) result.string;
374+ TCHAR* s = (TCHAR*) result.string;
376375 while (*s != '\0'){
376+#if !defined(UNICODE)
377377 if (String::isLeadByte(*s))
378378 s++;
379- else if (*s == oldChr)
379+ else
380+#endif
381+ if (*s == oldChr)
380382 *s = newChr;
381383 s++;
382384 }
@@ -387,11 +389,14 @@
387389 // 変換後の文字列。
388390 String toLowerCase()const {
389391 String result(string);
390- char* s = (char*) result.string;
392+ TCHAR* s = (TCHAR*) result.string;
391393 while (*s != '\0'){
394+#if !defined(UNICODE)
392395 if (String::isLeadByte(*s))
393396 s++;
394- else if ('A' <= *s && *s <= 'Z')
397+ else
398+#endif
399+ if ('A' <= *s && *s <= 'Z')
395400 *s += 'a' - 'A';
396401 s++;
397402 }
@@ -402,12 +407,15 @@
402407 // 変換後の文字列。
403408 String toUpperCase()const {
404409 String result(string);
405- char* s = (char*) result.string;
410+ TCHAR* s = (TCHAR*) result.string;
406411 while (*s != '\0'){
412+#if !defined(UNICODE)
407413 if (String::isLeadByte(*s))
408414 s++;
409- else if ('a' <= *s && *s <= 'z')
410- *s += 'A' - 'a';
415+ else
416+#endif
417+ if (_T('a') <= *s && *s <= _T('z'))
418+ *s += _T('A') - _T('a');
411419 s++;
412420 }
413421 return result;
@@ -416,12 +424,12 @@
416424 // 返値:
417425 // 削除後の文字列。
418426 String trim()const {
419- const char* s = string;
420- while (*s != '\0' && (unsigned char) *s <= ' ')
427+ const TCHAR* s = string;
428+ while (*s != '\0' && (TCHAR) *s <= _T(' '))
421429 s++;
422- const char* start = s;
430+ const TCHAR* start = s;
423431 s = string + length();
424- while (s > start && (*s != '\0' && (unsigned char) *s <= ' '))
432+ while (s > start && (*s != '\0' && (TCHAR) *s <= _T(' ')))
425433 s--;
426434 return String(start, s - start);
427435 }
@@ -428,19 +436,19 @@
428436
429437 // operators
430438
431- // const char*へのキャスト演算子
439+ // const TCHAR*へのキャスト演算子
432440 // 返値:
433441 // 文字列へのアドレス。
434- operator const char*()const {
442+ operator const TCHAR*()const {
435443 return string;
436444 }
437- // char配列のように扱うための[]演算子。
445+ // TCHAR配列のように扱うための[]演算子。
438446 // 引数:
439447 // index 取得する文字のインデックス。
440448 // 返値:
441449 // 指定のインデックスにある文字。
442- char operator[](size_t index)const {
443- return charAt(index);
450+ TCHAR operator[](size_t index)const {
451+ return TCHARAt(index);
444452 }
445453 // 文字列を連結するための+演算子。
446454 // 引数:
@@ -447,7 +455,7 @@
447455 // source 連結する文字列。
448456 // 返値:
449457 // 連結した文字列。
450- String operator+(const char* source)const {
458+ String operator+(const TCHAR* source)const {
451459 return String(string, source);
452460 }
453461 // 文字列を連結するための+演算子。
@@ -464,7 +472,7 @@
464472 // str2 連結する文字列(後)。
465473 // 返値:
466474 // 連結した文字列。
467- friend String operator+(const char* str1, const String& str2) {
475+ friend String operator+(const TCHAR* str1, const String& str2) {
468476 return *str1 != '\0' ? String(str1, str2.string) : str2;
469477 }
470478 // 代入演算子。
@@ -472,7 +480,7 @@
472480 // source 代入する文字列。
473481 // 返値:
474482 // 代入結果。
475- String& operator=(const char* source) {
483+ String& operator=(const TCHAR* source) {
476484 set(create(source));
477485 return *this;
478486 }
@@ -490,7 +498,7 @@
490498 // source 連結する文字列。
491499 // 返値:
492500 // 連結結果。
493- String& operator+=(const char* source) {
501+ String& operator+=(const TCHAR* source) {
494502 if (*source != '\0')
495503 set(concat(string, source));
496504 return *this;
@@ -508,7 +516,7 @@
508516 // str 比較対象の文字列。
509517 // 返値:
510518 // strの方が等しければ真。
511- bool operator==(const char* str)const {
519+ bool operator==(const TCHAR* str)const {
512520 return compareTo(str) == 0;
513521 }
514522 // 比較演算子。
@@ -517,7 +525,7 @@
517525 // str2 比較する文字列。
518526 // 返値:
519527 // str1よりstr2の方が等しければ真。
520- friend bool operator==(const char* str1, const String& str2) {
528+ friend bool operator==(const TCHAR* str1, const String& str2) {
521529 return str2.compareTo(str1) == 0;
522530 }
523531 // 比較演算子。
@@ -533,7 +541,7 @@
533541 // str 比較対象の文字列。
534542 // 返値:
535543 // strの方が等しくなければ真。
536- bool operator!=(const char* str)const {
544+ bool operator!=(const TCHAR* str)const {
537545 return compareTo(str) != 0;
538546 }
539547 // 比較演算子。
@@ -542,7 +550,7 @@
542550 // str2 比較する文字列。
543551 // 返値:
544552 // str1よりstr2の方が等しくなければ真。
545- friend bool operator!=(const char* str1, const String& str2) {
553+ friend bool operator!=(const TCHAR* str1, const String& str2) {
546554 return str2.compareTo(str1) != 0;
547555 }
548556 // 比較演算子。
@@ -558,7 +566,7 @@
558566 // str 比較対象の文字列。
559567 // 返値:
560568 // strの方が大きければ真。
561- bool operator<(const char* str)const {
569+ bool operator<(const TCHAR* str)const {
562570 return compareTo(str) < 0;
563571 }
564572 // 比較演算子。
@@ -567,7 +575,7 @@
567575 // str2 比較する文字列。
568576 // 返値:
569577 // str1よりstr2の方が大きければ真。
570- friend bool operator<(const char* str1, const String& str2) {
578+ friend bool operator<(const TCHAR* str1, const String& str2) {
571579 return str2.compareTo(str1) > 0;
572580 }
573581 // 比較演算子。
@@ -583,7 +591,7 @@
583591 // str 比較対象の文字列。
584592 // 返値:
585593 // strの方が大きいか等しければ真。
586- bool operator<=(const char* str)const {
594+ bool operator<=(const TCHAR* str)const {
587595 return compareTo(str) <= 0;
588596 }
589597 // 比較演算子。
@@ -592,7 +600,7 @@
592600 // str2 比較する文字列。
593601 // 返値:
594602 // str1よりstr2の方が大きいか等しければ真。
595- friend bool operator<=(const char* str1, const String& str2) {
603+ friend bool operator<=(const TCHAR* str1, const String& str2) {
596604 return str2.compareTo(str1) >= 0;
597605 }
598606 // 比較演算子。
@@ -608,7 +616,7 @@
608616 // str 比較対象の文字列。
609617 // 返値:
610618 // strの方が小さければ真。
611- bool operator>(const char* str)const {
619+ bool operator>(const TCHAR* str)const {
612620 return compareTo(str) > 0;
613621 }
614622 // 比較演算子。
@@ -617,7 +625,7 @@
617625 // str2 比較する文字列。
618626 // 返値:
619627 // str1よりstr2の方が小さければ真。
620- friend bool operator>(const char* str1, const String& str2) {
628+ friend bool operator>(const TCHAR* str1, const String& str2) {
621629 return str2.compareTo(str1) < 0;
622630 }
623631 // 比較演算子。
@@ -633,7 +641,7 @@
633641 // str 比較対象の文字列。
634642 // 返値:
635643 // strの方が小さいか等しければ真。
636- bool operator>=(const char* str)const {
644+ bool operator>=(const TCHAR* str)const {
637645 return compareTo(str) >= 0;
638646 }
639647 // 比較演算子。
@@ -642,7 +650,7 @@
642650 // str2 比較する文字列。
643651 // 返値:
644652 // str1よりstr2の方が小さいか等しければ真。
645- friend bool operator>=(const char* str1, const String& str2) {
653+ friend bool operator>=(const TCHAR* str1, const String& str2) {
646654 return str2.compareTo(str1) <= 0;
647655 }
648656
@@ -653,7 +661,8 @@
653661 // 判定するバイト。
654662 // 返値:
655663 // 2バイト文字の最初の1バイトであれば真。
656- static bool isLeadByte(char ch) {
664+#if !defined(UNICODE)
665+ static bool isLeadByte(TCHAR ch) {
657666 #ifdef _INC_WINDOWS
658667 return ::IsDBCSLeadByte(ch) != 0;
659668 #else
@@ -660,6 +669,7 @@
660669 return (ch & 0x80) != 0;
661670 #endif
662671 }
672+#endif
663673 };
664674
665675 }
--- branches/cmake/TTProxy/YCL/include/YCL/StringBuffer.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/StringBuffer.h (revision 7327)
@@ -14,6 +14,7 @@
1414 #include <YCL/String.h>
1515
1616 #include <malloc.h>
17+#include <tchar.h>
1718
1819 namespace yebisuya {
1920
@@ -21,7 +22,7 @@
2122 class StringBuffer {
2223 private:
2324 // 文字列を格納するバッファ。
24- char* buffer;
25+ TCHAR* buffer;
2526 // 現在有効な文字列の長さ。
2627 size_t validLength;
2728 // バッファの大きさ。
@@ -35,7 +36,7 @@
3536 // source 初期文字列。
3637 // length 初期文字列の長さ。
3738 // capacity バッファの初期サイズ。
38- void init(const char* source, size_t length, size_t capacity) {
39+ void init(const TCHAR* source, size_t length, size_t capacity) {
3940 if ((capacity != 0 || length != 0) && capacity < length + INIT_CAPACITY)
4041 capacity = length + INIT_CAPACITY;
4142 validLength = length;
@@ -43,10 +44,10 @@
4344 if (bufferSize == 0) {
4445 buffer = NULL;
4546 }else{
46- buffer = new char[bufferSize];
47+ buffer = new TCHAR[bufferSize];
4748 }
48- memcpy(buffer, source, validLength);
49- memset(buffer + validLength, '\0', bufferSize - validLength);
49+ memcpy(buffer, source, sizeof(TCHAR) * validLength);
50+ memset(buffer + validLength, '\0', sizeof(TCHAR) * (bufferSize - validLength));
5051 }
5152 public:
5253 // デフォルトコンストラクタ。
@@ -62,8 +63,8 @@
6263 // バッファの初期文字列を指定するコンストラクタ。
6364 // 引数:
6465 // source 初期文字列。
65- StringBuffer(const char* source) {
66- init(source, strlen(source), 0);
66+ StringBuffer(const TCHAR* source) {
67+ init(source, _tcslen(source), 0);
6768 }
6869 // コピーコンストラクタ。
6970 // 引数:
@@ -93,7 +94,7 @@
9394 // newLength 調節する長さ。
9495 void ensureCapacity(size_t newLength) {
9596 if (bufferSize < newLength) {
96- char* oldBuffer = buffer;
97+ TCHAR* oldBuffer = buffer;
9798 init(oldBuffer, validLength, newLength + INIT_CAPACITY);
9899 delete[] oldBuffer;
99100 }
@@ -111,8 +112,8 @@
111112 // index 文字の位置。
112113 // 返値:
113114 // 指定の位置の文字。
114- char charAt(size_t index)const {
115- return index >= 0 && index < validLength ? buffer[index] : '\0';
115+ TCHAR charAt(size_t index)const {
116+ return index < validLength ? buffer[index] : '\0';
116117 }
117118 // 指定の位置の文字を取得する。
118119 // 引数:
@@ -119,10 +120,8 @@
119120 // index 文字の位置。
120121 // 返値:
121122 // 指定の位置の文字の参照。
122- char& charAt(size_t index) {
123- if (index < 0) {
124- index = 0;
125- }else if (index >= validLength) {
123+ TCHAR& charAt(size_t index) {
124+ if (index >= validLength) {
126125 ensureCapacity(validLength + 1);
127126 index = validLength++;
128127 }
@@ -132,7 +131,7 @@
132131 // 引数:
133132 // index 変更する文字の位置。
134133 // chr 変更する文字。
135- void setCharAt(int index, char chr) {
134+ void setCharAt(int index, TCHAR chr) {
136135 charAt(index) = chr;
137136 }
138137 // 文字を追加する。
@@ -140,7 +139,7 @@
140139 // chr 追加する文字。
141140 // 返値:
142141 // 追加結果。
143- StringBuffer& append(char chr) {
142+ StringBuffer& append(TCHAR chr) {
144143 charAt(validLength) = chr;
145144 return *this;
146145 }
@@ -149,8 +148,8 @@
149148 // source 追加する文字列。
150149 // 返値:
151150 // 追加結果。
152- StringBuffer& append(const char* source) {
153- return append(source, strlen(source));
151+ StringBuffer& append(const TCHAR* source) {
152+ return append(source, _tcslen(source));
154153 }
155154 // 文字列を追加する。
156155 // 引数:
@@ -158,10 +157,10 @@
158157 // length 追加する文字列の長さ。
159158 // 返値:
160159 // 追加結果。
161- StringBuffer& append(const char* source, size_t length) {
160+ StringBuffer& append(const TCHAR* source, size_t length) {
162161 size_t oldLength = validLength;
163162 ensureCapacity(validLength + length);
164- memcpy(buffer + oldLength, source, length);
163+ memcpy(buffer + oldLength, source, sizeof(TCHAR) * length);
165164 validLength += length;
166165 return *this;
167166 }
@@ -184,7 +183,7 @@
184183 start = 0;
185184 if (start < end) {
186185 if (end < validLength){
187- memcpy(buffer + start, buffer + end, validLength - end);
186+ memcpy(buffer + start, buffer + end, sizeof(TCHAR) * (validLength - end));
188187 validLength -= end - start;
189188 }else{
190189 validLength = start;
@@ -199,17 +198,15 @@
199198 // source 置換する文字列。
200199 // 返値:
201200 // 置換結果。
202- StringBuffer& replace(size_t start, size_t end, const char* source) {
203- if (start < 0)
204- start = 0;
201+ StringBuffer& replace(size_t start, size_t end, const TCHAR* source) {
205202 if (end > validLength)
206203 end = validLength;
207204 if (start < end) {
208- size_t length = strlen(source);
205+ size_t length = _tcslen(source);
209206 size_t oldLength = validLength;
210207 ensureCapacity(validLength += length - (end - start));
211- memcpy(buffer + start + length, buffer + end, oldLength - end);
212- memcpy(buffer + start, source, length);
208+ memcpy(buffer + start + length, buffer + end, sizeof(TCHAR) * (oldLength - end));
209+ memcpy(buffer + start, source, sizeof(TCHAR) * length);
213210 }
214211 return *this;
215212 }
@@ -219,8 +216,6 @@
219216 // 返値:
220217 // 指定の位置の文字列。
221218 String substring(size_t index)const {
222- if (index < 0)
223- index = 0;
224219 return String(buffer + index, validLength - index);
225220 }
226221 // 指定の位置の文字列を取得する。
@@ -230,8 +225,6 @@
230225 // 返値:
231226 // 指定の位置の文字列。
232227 String substring(size_t start, size_t end)const {
233- if (start < 0)
234- start = 0;
235228 if (end > validLength)
236229 end = validLength;
237230 return String(buffer + start, end - start);
@@ -242,7 +235,7 @@
242235 // source 挿入する文字。
243236 // 返値:
244237 // 挿入結果。
245- StringBuffer& insert(size_t index, char chr) {
238+ StringBuffer& insert(size_t index, TCHAR chr) {
246239 return insert(index, &chr, 1);
247240 }
248241 // 指定の位置に文字列を挿入する。
@@ -251,8 +244,8 @@
251244 // source 挿入する文字列。
252245 // 返値:
253246 // 挿入結果。
254- StringBuffer& insert(size_t index, const char* source) {
255- return insert(index, source, strlen(source));
247+ StringBuffer& insert(size_t index, const TCHAR* source) {
248+ return insert(index, source, _tcslen(source));
256249 }
257250 // 指定の位置に文字列を挿入する。
258251 // 引数:
@@ -261,17 +254,15 @@
261254 // length 文字列の長さ。
262255 // 返値:
263256 // 挿入結果。
264- StringBuffer& insert(size_t index, const char* source, size_t length) {
265- if (index < 0)
266- index = 0;
267- else if (index >= validLength)
257+ StringBuffer& insert(size_t index, const TCHAR* source, size_t length) {
258+ if (index >= validLength)
268259 index = validLength;
269260 size_t oldLength = validLength;
270261 ensureCapacity(validLength + length);
271- char* temp = (char*) alloca(oldLength - index);
272- memcpy(temp, buffer + index, oldLength - index);
273- memcpy(buffer + index, source, length);
274- memcpy(buffer + index + length, temp, oldLength - index);
262+ TCHAR* temp = (TCHAR*) alloca(sizeof(TCHAR) * (oldLength - index));
263+ memcpy(temp, buffer + index, sizeof(TCHAR) * (oldLength - index));
264+ memcpy(buffer + index, source, sizeof(TCHAR) * length);
265+ memcpy(buffer + index + length, temp, sizeof(TCHAR) * (oldLength - index));
275266 validLength += length;
276267 return *this;
277268 }
@@ -279,19 +270,22 @@
279270 // 返値:
280271 // 反転結果。
281272 StringBuffer& reverse() {
282- char* temporary = (char*) alloca(sizeof (char) * validLength);
283- char* dst = temporary + validLength;
284- char* src = buffer;
273+ TCHAR* temporary = (TCHAR*) alloca(sizeof (TCHAR) * validLength);
274+ TCHAR* dst = temporary + validLength;
275+ TCHAR* src = buffer;
285276 while (temporary < dst) {
277+#if !defined(UNICODE)
286278 if (String::isLeadByte(*src)) {
287- char pre = *src++;
279+ TCHAR pre = *src++;
288280 *--dst = *src++;
289281 *--dst = pre;
290- }else{
282+ }else
283+#endif
284+ {
291285 *--dst = *src++;
292286 }
293287 }
294- memcpy(buffer, temporary, validLength);
288+ memcpy(buffer, temporary, sizeof(TCHAR) * validLength);
295289 return *this;
296290 }
297291 // 文字列を取得する。
@@ -306,7 +300,7 @@
306300 // 変更する一文字。
307301 // 返値:
308302 // 変更結果。
309- StringBuffer& set(char chr) {
303+ StringBuffer& set(TCHAR chr) {
310304 ensureCapacity(1);
311305 buffer[0] = chr;
312306 validLength = 1;
@@ -317,18 +311,18 @@
317311 // source 変更する文字列。
318312 // 返値:
319313 // 変更結果。
320- StringBuffer& set(const char* source) {
321- size_t length = strlen(source);
314+ StringBuffer& set(const TCHAR* source) {
315+ size_t length = _tcslen(source);
322316 ensureCapacity(validLength = length);
323- memcpy(buffer, source, length);
317+ memcpy(buffer, source, sizeof(TCHAR) * length);
324318 return *this;
325319 }
326320
327- // char*に変換するキャスト演算子。
321+ // TCHAR*に変換するキャスト演算子。
328322 // バッファのアドレスを取得する。
329323 // 返値:
330324 // バッファのアドレス。
331- operator char*() {
325+ operator TCHAR*() {
332326 return buffer;
333327 }
334328 // Stringに変換するキャスト演算子。
@@ -344,7 +338,7 @@
344338 // ch 変更する一文字。
345339 // 返値:
346340 // 代入結果。
347- StringBuffer& operator=(char ch) {
341+ StringBuffer& operator=(TCHAR ch) {
348342 return set(ch);
349343 }
350344 // 代入演算子。
@@ -353,7 +347,7 @@
353347 // source 変更する文字列。
354348 // 返値:
355349 // 代入結果。
356- StringBuffer& operator=(const char* source) {
350+ StringBuffer& operator=(const TCHAR* source) {
357351 return set(source);
358352 }
359353 // 連結代入演算子。
@@ -362,7 +356,7 @@
362356 // ch 追加する文字。
363357 // 返値:
364358 // 代入結果。
365- StringBuffer& operator+=(char ch) {
359+ StringBuffer& operator+=(TCHAR ch) {
366360 return append(ch);
367361 }
368362 // 連結代入演算子。
@@ -371,7 +365,7 @@
371365 // source 追加する文字列。
372366 // 返値:
373367 // 代入結果。
374- StringBuffer& operator+=(const char* source) {
368+ StringBuffer& operator+=(const TCHAR* source) {
375369 return append(source);
376370 }
377371 };
--- branches/cmake/TTProxy/YCL/include/YCL/StringUtil.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/StringUtil.h (revision 7327)
@@ -18,7 +18,7 @@
1818
1919 class StringUtil {
2020 private:
21- static int hexadecimal(char c) {
21+ static int hexadecimal(TCHAR c) {
2222 if ('0' <= c && c <= '9') {
2323 return c - '0';
2424 }else if ('A' <= c && c <= 'F') {
@@ -29,15 +29,15 @@
2929 return -1;
3030 }
3131 }
32- static int octet(char c) {
32+ static int octet(TCHAR c) {
3333 return '0' <= c && c <= '7' ? c - '0' : -1;
3434 }
35- static const char* ESCAPE_CHARS() {
36- static const char string[] = "abfnrtv";
35+ static const TCHAR* ESCAPE_CHARS() {
36+ static const TCHAR string[] = _T("abfnrtv");
3737 return string;
3838 }
39- static const char* CONTROL_CHARS() {
40- static const char string[] = "\a\b\f\n\r\t\v";
39+ static const TCHAR* CONTROL_CHARS() {
40+ static const TCHAR string[] = _T("\a\b\f\n\r\t\v");
4141 return string;
4242 }
4343 public:
@@ -60,12 +60,12 @@
6060 static bool escape(StringBuffer& buffer, String string, int offset, int length) {
6161 if (string == NULL)
6262 return false;
63- const char* start = string;
63+ const TCHAR* start = string;
6464 start += offset;
65- const char* p = start;
66- const char* end = start + length;
65+ const TCHAR* p = start;
66+ const TCHAR* end = start + length;
6767 while (p < end && *p != '\0') {
68- char ch = *p;
68+ TCHAR ch = *p;
6969 if ('\0' < ch && ch < ' ' || ch == '\'' || ch == '"' || ch == '?' || ch == '\\') {
7070 bool useOctet;
7171 if (ch < ' ') {
@@ -95,12 +95,14 @@
9595 }
9696 start = ++p;
9797 }else{
98+#if !defined(UNICODE)
9899 if (String::isLeadByte(ch))
99100 p++;
101+#endif
100102 p++;
101103 }
102104 }
103- if (start == (const char*) string) {
105+ if (start == (const TCHAR*) string) {
104106 return false;
105107 }
106108 buffer.append(start);
@@ -126,10 +128,10 @@
126128 static bool unescape(StringBuffer& buffer, String string, int offset, int length) {
127129 if (string == NULL)
128130 return false;
129- const char* start = string;
131+ const TCHAR* start = string;
130132 start += offset;
131- const char* p = start;
132- const char* end = start + length;
133+ const TCHAR* p = start;
134+ const TCHAR* end = start + length;
133135 while (p < end && *p != '\0') {
134136 if (*p == '\\') {
135137 if (p > start) {
@@ -136,7 +138,7 @@
136138 buffer.append(start, p - start);
137139 start = p;
138140 }
139- char ch = '\0';
141+ TCHAR ch = '\0';
140142 switch (*++p) {
141143 case '\'':
142144 case '"':
@@ -188,13 +190,15 @@
188190 start = p;
189191 }
190192 }else{
193+#if !defined(UNICODE)
191194 if (String::isLeadByte(*p)) {
192195 p++;
193196 }
197+#endif
194198 p++;
195199 }
196200 }
197- if (start == (const char*) string) {
201+ if (start == (const TCHAR*) string) {
198202 return false;
199203 }
200204 buffer.append(start);
--- branches/cmake/TTProxy/YCL/include/YCL/Window.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/Window.h (revision 7327)
@@ -10,8 +10,8 @@
1010 #endif // _MSC_VER >= 1000
1111
1212 #include <YCL/common.h>
13-
1413 #include <YCL/String.h>
14+//#include "codeconv.h"
1515
1616 namespace yebisuya {
1717
@@ -39,16 +39,16 @@
3939 int GetWindowTextLength()const {
4040 return ::GetWindowTextLength(window);
4141 }
42- int GetWindowText(char* buffer, int size)const {
42+ int GetWindowText(TCHAR* buffer, int size)const {
4343 return ::GetWindowText(window, buffer, size);
4444 }
4545 String GetWindowText()const {
4646 int length = GetWindowTextLength();
47- char* buffer = (char*) alloca(length + 1);
47+ TCHAR* buffer = (TCHAR*) alloca((length + 1) * sizeof(TCHAR));
4848 GetWindowText(buffer, length + 1);
49- return buffer;
49+ return String(buffer);
5050 }
51- bool SetWindowText(const char* text) {
51+ bool SetWindowText(const TCHAR* text) {
5252 return ::SetWindowText(window, text) != FALSE;
5353 }
5454 long SendMessage(int message, int wparam = 0, long lparam = 0)const {
@@ -208,7 +208,7 @@
208208 static const char USER32[] = "user32.dll";
209209 static const char APINAME[] = "SetLayeredWindowAttributes";
210210 static DWORD (WINAPI* api)(HWND, DWORD, BYTE, DWORD)
211- = (DWORD (WINAPI*)(HWND, DWORD, BYTE, DWORD)) ::GetProcAddress(::GetModuleHandle(USER32), APINAME);
211+ = (DWORD (WINAPI*)(HWND, DWORD, BYTE, DWORD)) ::GetProcAddress(::GetModuleHandleA(USER32), APINAME);
212212 return api != NULL ? (*api)(window, reserved, parameters, attribute) : 0;
213213 }
214214 long SetLayeredWindowAttributes(int parameters, long attribute) {
@@ -226,10 +226,10 @@
226226 bool UnregisterHotKey(int id) {
227227 return ::UnregisterHotKey(window, id) != FALSE;
228228 }
229- int MessageBox(const char* message, const char* caption, int type) {
229+ int MessageBox(const TCHAR* message, const TCHAR* caption, int type) {
230230 return ::MessageBox(window, message, caption, type);
231231 }
232- int MessageBox(const char* message, int type) {
232+ int MessageBox(const TCHAR* message, int type) {
233233 Window top(window);
234234 while ((top.getStyle() & WS_CHILD) != 0) {
235235 top <<= top.GetParent();
@@ -247,7 +247,7 @@
247247 return create(exStyle, classname, title, style, rect, parent, menu, GetInstanceHandle(), param);
248248 }
249249 bool create(long exStyle, const char* classname, const char* title, long style, const RECT& rect, HWND parent, HMENU menu, HINSTANCE instance, void* param = NULL) {
250- return (window = ::CreateWindowEx(exStyle, classname, title,
250+ return (window = ::CreateWindowExA(exStyle, classname, title,
251251 style, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
252252 parent, menu, instance, param)) != NULL;
253253 }
--- branches/cmake/TTProxy/YCL/include/YCL/common.h (revision 7326)
+++ branches/cmake/TTProxy/YCL/include/YCL/common.h (revision 7327)
@@ -38,9 +38,9 @@
3838 char buffer[1025];
3939 va_list arglist;
4040 va_start(arglist, format);
41- wvsprintf(buffer, format, arglist);
41+ wvsprintfA(buffer, format, arglist);
4242 va_end(arglist);
43- OutputDebugString(buffer);
43+ OutputDebugStringA(buffer);
4444 }
4545
4646 #define YCLTRACE(s) OutputDebugString(s)
@@ -53,12 +53,12 @@
5353 inline bool YclAssert(bool condition, const char* message) {
5454 if (!condition) {
5555 char buffer[1025];
56- wsprintf(buffer, "Assertion Failed!!\n\n"
56+ wsprintfA(buffer, "Assertion Failed!!\n\n"
5757 " %s\n\n"
5858 "if ABORT button pushed then exit this program,\n"
5959 "if RETRY button pushed then enter debug mode,\n"
6060 "and if IGNORE button pushed then continue program.", message);
61- switch (MessageBox(NULL, buffer, "YEBISUYA Class Library", MB_ABORTRETRYIGNORE | MB_ICONWARNING)) {
61+ switch (MessageBoxA(NULL, buffer, "YEBISUYA Class Library", MB_ABORTRETRYIGNORE | MB_ICONWARNING)) {
6262 case IDABORT:
6363 ExitProcess(-1);
6464 break;
--- branches/cmake/teraterm/common/codeconv.cpp (revision 7326)
+++ branches/cmake/teraterm/common/codeconv.cpp (revision 7327)
@@ -148,3 +148,271 @@
148148 return strU8;
149149 }
150150
151+//////////////////////////////////////////////////////////////////////////////
152+
153+u8::u8()
154+{
155+ u8str_ = NULL;
156+}
157+
158+u8::u8(const char *astr)
159+{
160+ u8str_ = NULL;
161+ assign(astr, CP_ACP);
162+}
163+
164+u8::u8(const char *astr, int cpage)
165+{
166+ u8str_ = NULL;
167+ assign(astr, cpage);
168+}
169+
170+u8::u8(const wchar_t *wstr)
171+{
172+ u8str_ = NULL;
173+ assign(wstr);
174+}
175+
176+u8::u8(const u8 &obj)
177+{
178+ copy(obj);
179+}
180+
181+#if defined(MOVE_CONSTRUCTOR_ENABLE)
182+u8::u8(u8 &&obj) noexcept
183+{
184+ move(obj);
185+}
186+#endif
187+
188+u8::~u8()
189+{
190+ if (u8str_ != NULL) {
191+ free(u8str_);
192+ u8str_ = NULL;
193+ }
194+}
195+
196+u8& u8::operator=(const char *astr)
197+{
198+ assign(astr, CP_ACP);
199+ return *this;
200+}
201+
202+u8& u8::operator=(const wchar_t *wstr)
203+{
204+ assign(wstr);
205+ return *this;
206+}
207+
208+u8& u8::operator=(const u8 &obj)
209+{
210+ copy(obj);
211+ return *this;
212+}
213+
214+#if defined(MOVE_CONSTRUCTOR_ENABLE)
215+u8& u8::operator=(u8 &&obj) noexcept
216+{
217+ move(obj);
218+ return *this;
219+}
220+#endif
221+
222+u8::operator const char *() const
223+{
224+ return cstr();
225+}
226+
227+const char *u8::cstr() const
228+{
229+ if (u8str_ == NULL) {
230+ return "";
231+ }
232+ return u8str_;
233+}
234+
235+void u8::assign(const char *astr, int code_page)
236+{
237+ if (u8str_ != NULL) {
238+ free(u8str_);
239+ }
240+ wchar_t *wstr = _MultiByteToWideChar(astr, 0, code_page, NULL);
241+ if (wstr != NULL) {
242+ assign(wstr);
243+ free(wstr);
244+ } else {
245+ u8str_ = NULL;
246+ }
247+}
248+
249+void u8::assign(const wchar_t *wstr)
250+{
251+ if (u8str_ != NULL) {
252+ free(u8str_);
253+ }
254+ char *u8str = _WideCharToMultiByte(wstr, 0, CP_UTF8, NULL);
255+ if (u8str != NULL) {
256+ u8str_ = u8str;
257+ } else {
258+ u8str_ = NULL;
259+ }
260+}
261+
262+void u8::copy(const u8 &obj)
263+{
264+ if (u8str_ != NULL) {
265+ free(u8str_);
266+ }
267+ u8str_ = _strdup(obj.u8str_);
268+}
269+
270+void u8::move(u8 &obj)
271+{
272+ if (this != &obj) {
273+ if (u8str_ != NULL) {
274+ free(u8str_);
275+ }
276+ u8str_ = obj.u8str_;
277+ obj.u8str_ = NULL;
278+ }
279+}
280+
281+//////////////////////////////////////////////////////////////////////////////
282+
283+tc::tc()
284+{
285+ tstr_ = NULL;
286+}
287+
288+tc::tc(const char *astr)
289+{
290+ tstr_ = NULL;
291+ assign(astr, CP_ACP);
292+}
293+
294+tc::tc(const char *astr, int code_page)
295+{
296+ tstr_ = NULL;
297+ assign(astr, code_page);
298+}
299+
300+tc::tc(const wchar_t *wstr)
301+{
302+ tstr_ = NULL;
303+ assign(wstr, CP_ACP);
304+}
305+
306+tc::tc(const wchar_t *wstr, int code_page)
307+{
308+ tstr_ = NULL;
309+ assign(wstr, code_page);
310+}
311+
312+#if defined(MOVE_CONSTRUCTOR_ENABLE)
313+tc::tc(tc &&obj) noexcept
314+{
315+ move(obj);
316+}
317+#endif
318+
319+tc::~tc()
320+{
321+ if (tstr_ != NULL) {
322+ free(tstr_);
323+ }
324+}
325+
326+tc& tc::operator=(const char *astr)
327+{
328+ assign(astr, CP_ACP);
329+ return *this;
330+}
331+
332+tc& tc::operator=(const wchar_t *wstr)
333+{
334+ assign(wstr, CP_ACP);
335+ return *this;
336+}
337+
338+const TCHAR *tc::fromUtf8(const char *u8str)
339+{
340+ if (tstr_ != NULL) {
341+ free(tstr_);
342+ }
343+ tstr_ = NULL;
344+ wchar_t *wstr = _MultiByteToWideChar(u8str, 0, CP_UTF8, NULL);
345+ if (wstr != NULL) {
346+ assign(wstr, CP_ACP);
347+ free(wstr);
348+ }
349+ return cstr();
350+}
351+
352+tc::operator const TCHAR *() const
353+{
354+ return cstr();
355+}
356+
357+const TCHAR *tc::cstr() const
358+{
359+ if (tstr_ == NULL) {
360+ return _T("");
361+ }
362+ return tstr_;
363+}
364+
365+void tc::assign(const char *astr, int code_page)
366+{
367+ if (tstr_ != NULL) {
368+ free(tstr_);
369+ }
370+#if !defined(UNICODE)
371+ (void)code_page;
372+ tstr_ = _strdup(astr);
373+#else
374+ wchar_t *wstr = _MultiByteToWideChar(astr, 0, code_page, NULL);
375+ if (wstr != NULL) {
376+ tstr_ = wstr;
377+ } else {
378+ tstr_ = NULL;
379+ }
380+#endif
381+}
382+
383+void tc::assign(const wchar_t *wstr, int code_page)
384+{
385+ if (tstr_ != NULL) {
386+ free(tstr_);
387+ }
388+#if defined(UNICODE)
389+ (void)code_page;
390+ tstr_ = _wcsdup(wstr);
391+#else
392+ char *astr = _WideCharToMultiByte(wstr, 0, code_page, NULL);
393+ if (astr != NULL) {
394+ tstr_ = astr;
395+ } else {
396+ tstr_ = NULL;
397+ }
398+#endif
399+}
400+
401+void tc::copy(const tc &obj)
402+{
403+ if (tstr_ != NULL) {
404+ free(tstr_);
405+ }
406+ tstr_ = _tcsdup(obj.tstr_);
407+}
408+
409+void tc::move(tc &obj)
410+{
411+ if (this != &obj) {
412+ if (tstr_ != NULL) {
413+ free(tstr_);
414+ }
415+ tstr_ = obj.tstr_;
416+ obj.tstr_ = NULL;
417+ }
418+}
--- branches/cmake/teraterm/common/codeconv.h (revision 7326)
+++ branches/cmake/teraterm/common/codeconv.h (revision 7327)
@@ -1,4 +1,6 @@
11 
2+#pragma once
3+
24 #include <tchar.h>
35
46 #ifdef __cplusplus
@@ -33,3 +35,70 @@
3335 TCHAR *ToTchar(const wchar_t *strW);
3436 #endif
3537
38+
39+#ifdef __cplusplus
40+
41+#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1910))
42+#define MOVE_CONSTRUCTOR_ENABLE
43+#endif
44+
45+class u8
46+{
47+public:
48+ u8();
49+ u8(const char *astr);
50+ u8(const char *astr, int code_page);
51+ u8(const wchar_t *wstr);
52+ u8(const u8 &obj);
53+#if defined(MOVE_CONSTRUCTOR_ENABLE)
54+ u8(u8 &&obj) noexcept;
55+#endif
56+ ~u8();
57+ u8& operator=(const char *astr);
58+ u8& operator=(const wchar_t *wstr);
59+ u8& operator=(const u8 &obj);
60+#if defined(MOVE_CONSTRUCTOR_ENABLE)
61+ u8& operator=(u8 &&obj) noexcept;
62+#endif
63+ operator const char *() const;
64+ const char *cstr() const;
65+private:
66+ char *u8str_;
67+ void assign(const char *astr, int code_page);
68+ void assign(const wchar_t *wstr);
69+ void copy(const u8 &obj);
70+ void move(u8 &obj);
71+};
72+
73+class tc
74+{
75+public:
76+ tc();
77+ tc(const char *astr);
78+ tc(const char *astr, int code_page);
79+ tc(const wchar_t *wstr);
80+ tc(const wchar_t *wstr, int code_page);
81+ tc(const tc &obj);
82+#if defined(MOVE_CONSTRUCTOR_ENABLE)
83+ tc(tc &&obj) noexcept;
84+#endif
85+ ~tc();
86+ tc& operator=(const char *astr);
87+ tc& operator=(const wchar_t *wstr);
88+ tc& operator=(const tc &obj);
89+#if defined(MOVE_CONSTRUCTOR_ENABLE)
90+ tc& operator=(tc &&obj) noexcept;
91+#endif
92+ const TCHAR *fromUtf8(const char *u8str);
93+ operator const TCHAR *() const;
94+ const TCHAR *cstr() const;
95+private:
96+ TCHAR *tstr_;
97+ void assign(const char *astr, int code_page);
98+ void assign(const wchar_t *astr, int code_page);
99+ void copy(const tc &obj);
100+ void move(tc &obj);
101+};
102+#endif
103+
104+
Show on old repository browser