Skip to content

Commit 0337f12

Browse files
committed
Unicode fix (not complete yet)
1 parent 84ef691 commit 0337f12

37 files changed

+154
-147
lines changed

BuildMenu/BuildMenu.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@
1212
static char THIS_FILE[] = __FILE__;
1313
#endif
1414

15-
/* Menu 和 Command Item的結構
15+
/* Menu 和 Command Item的結構
1616
17-
檔案內部儲存方式:
17+
檔案內部儲存方式:
1818
WORD MAIN_ITEM_COUNT
1919
CMDITEM ITEMS[TOTAL_COUNT]
2020
DWORD ACCELCOUNT
2121
ACCEL ACC_ITEMS[ACCELCOUNT]
2222
2323
struct CMDITEM
2424
{
25-
BYTE TYPE, CT_MENU,CT_HAS_SUB,CT_CMD,如果TYPE=0則為Separator,後面幾項都沒有
26-
WORD ID_OR_SUBCOUNT 如果有CT_HAS_SUB,為SUBCOUNT,如果沒有則為ID
27-
WORD state 只有Menu才有此項目
28-
WORD LEN TEXT的長度,含0
29-
CHAR TEXT[] 長度不定,0結尾
25+
BYTE TYPE, CT_MENU,CT_HAS_SUB,CT_CMD,如果TYPE=0則為Separator,後面幾項都沒有
26+
WORD ID_OR_SUBCOUNT 如果有CT_HAS_SUB,為SUBCOUNT,如果沒有則為ID
27+
WORD state 只有Menu才有此項目
28+
WORD LEN TEXT的長度,含0
29+
CHAR TEXT[] 長度不定,0結尾
3030
}
3131
3232
*/
3333

34-
// 用來產生UI檔的程式碼
34+
// 用來產生UI檔的程式碼
3535
void UIWriteMenu(CBuffer& ui, HMENU hmenu, char* text, WORD state)
3636
{
3737
CMenu menu; menu.Attach(hmenu);
@@ -80,7 +80,7 @@ void UIWriteMenu(CBuffer& ui, HMENU hmenu, char* text, WORD state)
8080

8181
std::unique_ptr<CBuffer> BuildUIBuffer()
8282
{
83-
// 用來產生UI檔的程式碼
83+
// 用來產生UI檔的程式碼
8484
std::unique_ptr<CBuffer> ui(new CBuffer());
8585

8686
// MessageBox( NULL, OutPath, NULL, MB_OK );

Lite/AES.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ CAES::~CAES()
2424

2525
}
2626

27-
28-
void CAES::EnterPassword(CString passwd)
27+
// ANSI hack, CStringA
28+
void CAES::EnterPassword(CStringA passwd)
2929
{
3030
int len = (passwd.GetLength() / 16 + (passwd.GetLength() % 16 ? 1 : 0)) * 16;
3131
char pad[32];

Lite/AES.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
class CAES : public CRijndael
1616
{
1717
public:
18-
void EnterPassword(CString passwd);
18+
// ANSI hack, CStringA
19+
void EnterPassword(CStringA passwd);
1920
inline BOOL IsInitialized(){ return m_bInit; }
2021
CAES();
2122
virtual ~CAES();

Lite/AddressDlg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ CString CAddressDlg::GetFormattedAddress() const
3434
if (port == 23 || port <= 0)
3535
return address;
3636
CString buf;
37-
buf.Format("%s:%d", LPCTSTR(address), port);
37+
buf.Format(TEXT("%s:%d"), LPCTSTR(address), port);
3838
return buf;
3939
}
4040

@@ -52,7 +52,7 @@ BOOL CAddressDlg::OnInitDialog()
5252
{
5353
CComboBox* combo = (CComboBox*)GetDlgItem(IDC_ADDRESS);
5454
combo->SetWindowText(address);
55-
GetDlgItem(IDC_PORT)->SetWindowText("23");
55+
GetDlgItem(IDC_PORT)->SetWindowText(TEXT("23"));
5656

5757
POSITION pos = AppConfig.history.GetHeadPosition();
5858
CString str;
@@ -108,7 +108,7 @@ void CAddressDlg::OnAddressChanged()
108108
if (addr.IsValid())
109109
{
110110
CString port_text;
111-
port_text.Format("%d", addr.Port());
111+
port_text.Format(TEXT("%d"), addr.Port());
112112
port_field->SetWindowText(port_text);
113113
}
114-
}
114+
}

Lite/AnsiBar.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void CAnsiBar::OnBk()
4545
mnu.CreatePopupMenu();
4646
for (int i = 10;i < 18;i++)
4747
{
48-
mnu.AppendMenu(MF_OWNERDRAW, i, "");
48+
mnu.AppendMenu(MF_OWNERDRAW, i, TEXT(""));
4949
}
5050
CRect rc;
5151
::GetWindowRect(::GetDlgItem(m_hWnd, IDC_ANSIBAR_BK), rc);
@@ -67,7 +67,7 @@ void CAnsiBar::OnFg()
6767
mnu.CreatePopupMenu();
6868
for (int i = 10;i < 26;i++)
6969
{
70-
mnu.AppendMenu(MF_OWNERDRAW, i, "");
70+
mnu.AppendMenu(MF_OWNERDRAW, i, TEXT(""));
7171
}
7272
CRect rc;
7373
::GetWindowRect(::GetDlgItem(m_hWnd, IDC_ANSIBAR_FG), rc);
@@ -108,7 +108,7 @@ void CAnsiBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
108108
if (GetRValue(clr) <= 128 && GetGValue(clr) <= 128 && GetBValue(clr) <= 128)
109109
txtclr = 0xffffff;
110110
dc.SetTextColor(txtclr);
111-
char txt[5];
111+
TCHAR txt[5];
112112
dc.DrawEdge(&lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState&ODS_SELECTED ? EDGE_SUNKEN : EDGE_RAISED, BF_RECT);
113113
::GetWindowText(lpDrawItemStruct->hwndItem, txt, 5);
114114
dc.DrawText(txt, 4, &lpDrawItemStruct->rcItem, DT_VCENTER | DT_CENTER | DT_SINGLELINE);

Lite/AppConfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ CString GetIEPath()
116116
HKEY hk = NULL;
117117
// RegOpenKey( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE", &hk );
118118
// RegQueryValue( hk, NULL, fpath.GetBuffer(_MAX_PATH), &len);
119-
RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE", fpath.GetBuffer(_MAX_PATH), &len);
119+
RegQueryValue(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE"), fpath.GetBuffer(_MAX_PATH), &len);
120120
// RegCloseKey( hk );
121121
fpath.ReleaseBuffer();
122122
return fpath;

Lite/AutoComplete.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ int CAutoComplete::CompareItem(const void *p1, const void *p2)
277277
int r = item1->strstrpos - item2->strstrpos;
278278
if (0 != r)
279279
return r;
280-
return strcmp(m_pOpenedList->m_pSrc->GetAt(item1->strpos),
280+
return _tcscmp(m_pOpenedList->m_pSrc->GetAt(item1->strpos),
281281
m_pOpenedList->m_pSrc->GetAt(item2->strpos));
282282
}
283283

Lite/AutoReplyPage.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ void CAutoReplyPage::OnAdd()
7474
msg.SetWindowText(NULL);
7575
respond.SetWindowText(NULL);
7676
protect.SetCheck(FALSE);
77-
first.SetWindowText("1");
78-
count.SetWindowText("1");
77+
first.SetWindowText(TEXT("1"));
78+
count.SetWindowText(TEXT("1"));
7979
list.EnableWindow(FALSE);
8080
}
8181

@@ -197,20 +197,20 @@ void CAutoReplyPage::UpdateDisplay()
197197
msg.SetWindowText(item->msg);
198198
respond.SetPasswordChar(*LPCTSTR(item->respond) == '+' ? '*' : 0);
199199
CString tmp = LPCTSTR(item->respond) + 1;
200-
tmp.Replace("^M^J", "\r\n");
201-
tmp.Replace("^M", "\r\n");
200+
tmp.Replace(TEXT("^M^J"), TEXT("\r\n"));
201+
tmp.Replace(TEXT("^M"), TEXT("\r\n"));
202202
respond.SetWindowText(tmp);
203203
protect.SetCheck(*LPCTSTR(item->respond) == '+');
204204

205-
char sfirst[8];
206-
itoa(item->first, sfirst, 10);
205+
TCHAR sfirst[8];
206+
_itot(item->first, sfirst, 10);
207207
first.SetWindowText(sfirst);
208-
char scount[8];
208+
TCHAR scount[8];
209209
if (item->count == 0)
210210
count.SetWindowText(NULL);
211211
else
212212
{
213-
itoa(item->count, scount, 10);
213+
_itot(item->count, scount, 10);
214214
count.SetWindowText(scount);
215215
}
216216
}
@@ -247,21 +247,21 @@ void CAutoReplyPage::OnSave()
247247
item->msg = tmp;
248248

249249
respond.GetWindowText(tmp);
250-
tmp.Replace("\r\n", "^M");
250+
tmp.Replace(TEXT("\r\n"), TEXT("^M"));
251251
item->respond = protect.GetCheck() ? "+" : "-";
252252
item->respond += tmp;
253253

254-
char sfirst[8];
254+
TCHAR sfirst[8];
255255
first.GetWindowText(sfirst, 8);
256-
item->first = atoi(sfirst);
256+
item->first = _tstoi(sfirst);
257257
if (item->first < 1)
258258
item->first = 1;
259-
char scount[8];
259+
TCHAR scount[8];
260260
count.GetWindowText(scount, 8);
261261
if (!*scount)
262262
item->count = 0;
263263
else
264-
item->count = atoi(scount);
264+
item->count = _tstoi(scount);
265265

266266
if (badd) //如果新增
267267
i = list.AddString(item->msg);

Lite/AutoUpdate.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static char THIS_FILE[]=__FILE__;
2424
CAutoUpdater::CAutoUpdater()
2525
{
2626
// Initialize WinInet
27-
hInternet = InternetOpen("AutoUpdateAgent", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
27+
hInternet = InternetOpen(TEXT("AutoUpdateAgent"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
2828
}
2929

3030
CAutoUpdater::~CAutoUpdater()
@@ -144,7 +144,7 @@ CAutoUpdater::ErrorType CAutoUpdater::CheckForUpdate()
144144
// }
145145

146146
MessageBox(AfxGetMainWnd()->m_hWnd, LoadString(IDS_INSTALL_UPDATE), LoadString(IDS_PCMAN_CLOSE), MB_ICONINFORMATION|MB_OK);
147-
if (!::ShellExecute(AfxGetMainWnd()->m_hWnd, "open", updateFileLocation, NULL, NULL,
147+
if (!::ShellExecute(AfxGetMainWnd()->m_hWnd, TEXT("open"), updateFileLocation, NULL, NULL,
148148
SW_SHOWNORMAL))
149149
{
150150
return UpdateNotComplete;
@@ -325,7 +325,7 @@ int CAutoUpdater::CompareVersions(CString ver1, CString ver2)
325325
}
326326

327327
// Get version 1 to DWORDs
328-
TCHAR *pToken = strtok(pVer1, _T("."));
328+
TCHAR *pToken = _tcstok(pVer1, _T("."));
329329
if (pToken == NULL)
330330
{
331331
return -21;
@@ -338,14 +338,14 @@ int CAutoUpdater::CompareVersions(CString ver1, CString ver2)
338338
{
339339
return -21; // Error in structure, too many parameters
340340
}
341-
wVer1[i] = atoi(pToken);
342-
pToken = strtok(NULL, _T("."));
341+
wVer1[i] = _tstoi(pToken);
342+
pToken = _tcstok(NULL, _T("."));
343343
i--;
344344
}
345345
ver1.ReleaseBuffer();
346346

347347
// Get version 2 to DWORDs
348-
pToken = strtok(pVer2, _T("."));
348+
pToken = _tcstok(pVer2, _T("."));
349349
if (pToken == NULL)
350350
{
351351
return -22;
@@ -358,8 +358,8 @@ int CAutoUpdater::CompareVersions(CString ver1, CString ver2)
358358
{
359359
return -22; // Error in structure, too many parameters
360360
}
361-
wVer2[i] = atoi(pToken);
362-
pToken = strtok(NULL, _T("."));
361+
wVer2[i] = _tstoi(pToken);
362+
pToken = _tcstok(NULL, _T("."));
363363
i--;
364364
}
365365
ver2.ReleaseBuffer();

Lite/AutoUpdate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#endif
2424

2525
#define LOCATION_UPDATE_FILE_CHECK _T(UPDATE_FILE)
26-
static UINT NEAR WM_COMMIT_UPDATE = RegisterWindowMessage("COMMIT_UPDATE");
27-
static UINT NEAR WM_DOWNLOAD_UPDATE_COMPLETE = RegisterWindowMessage("DOWNLOAD_UPDATE_COMPLETE");
26+
static UINT NEAR WM_COMMIT_UPDATE = RegisterWindowMessage(TEXT("COMMIT_UPDATE"));
27+
static UINT NEAR WM_DOWNLOAD_UPDATE_COMPLETE = RegisterWindowMessage(TEXT("DOWNLOAD_UPDATE_COMPLETE"));
2828

2929
class CAutoUpdater
3030
{

0 commit comments

Comments
 (0)