Skip to content

Commit

Permalink
Unicode fix (not complete yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
craftwar committed Aug 27, 2018
1 parent 84ef691 commit 0337f12
Show file tree
Hide file tree
Showing 37 changed files with 154 additions and 147 deletions.
18 changes: 9 additions & 9 deletions BuildMenu/BuildMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
static char THIS_FILE[] = __FILE__;
#endif

/* Menu 和 Command Item的結構
/* Menu 和 Command Item的結構
檔案內部儲存方式:
檔案內部儲存方式:
WORD MAIN_ITEM_COUNT
CMDITEM ITEMS[TOTAL_COUNT]
DWORD ACCELCOUNT
ACCEL ACC_ITEMS[ACCELCOUNT]
struct CMDITEM
{
BYTE TYPE, CT_MENU,CT_HAS_SUB,CT_CMD,如果TYPE=0則為Separator,後面幾項都沒有
WORD ID_OR_SUBCOUNT 如果有CT_HAS_SUB,為SUBCOUNT,如果沒有則為ID
WORD state 只有Menu才有此項目
WORD LEN TEXT的長度,含0
CHAR TEXT[] 長度不定,0結尾
BYTE TYPE, CT_MENU,CT_HAS_SUB,CT_CMD,如果TYPE=0則為Separator,後面幾項都沒有
WORD ID_OR_SUBCOUNT 如果有CT_HAS_SUB,為SUBCOUNT,如果沒有則為ID
WORD state 只有Menu才有此項目
WORD LEN TEXT的長度,含0
CHAR TEXT[] 長度不定,0結尾
}
*/

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

std::unique_ptr<CBuffer> BuildUIBuffer()
{
// 用來產生UI檔的程式碼
// 用來產生UI檔的程式碼
std::unique_ptr<CBuffer> ui(new CBuffer());

// MessageBox( NULL, OutPath, NULL, MB_OK );
Expand Down
4 changes: 2 additions & 2 deletions Lite/AES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ CAES::~CAES()

}


void CAES::EnterPassword(CString passwd)
// ANSI hack, CStringA
void CAES::EnterPassword(CStringA passwd)
{
int len = (passwd.GetLength() / 16 + (passwd.GetLength() % 16 ? 1 : 0)) * 16;
char pad[32];
Expand Down
3 changes: 2 additions & 1 deletion Lite/AES.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
class CAES : public CRijndael
{
public:
void EnterPassword(CString passwd);
// ANSI hack, CStringA
void EnterPassword(CStringA passwd);
inline BOOL IsInitialized(){ return m_bInit; }
CAES();
virtual ~CAES();
Expand Down
8 changes: 4 additions & 4 deletions Lite/AddressDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CString CAddressDlg::GetFormattedAddress() const
if (port == 23 || port <= 0)
return address;
CString buf;
buf.Format("%s:%d", LPCTSTR(address), port);
buf.Format(TEXT("%s:%d"), LPCTSTR(address), port);
return buf;
}

Expand All @@ -52,7 +52,7 @@ BOOL CAddressDlg::OnInitDialog()
{
CComboBox* combo = (CComboBox*)GetDlgItem(IDC_ADDRESS);
combo->SetWindowText(address);
GetDlgItem(IDC_PORT)->SetWindowText("23");
GetDlgItem(IDC_PORT)->SetWindowText(TEXT("23"));

POSITION pos = AppConfig.history.GetHeadPosition();
CString str;
Expand Down Expand Up @@ -108,7 +108,7 @@ void CAddressDlg::OnAddressChanged()
if (addr.IsValid())
{
CString port_text;
port_text.Format("%d", addr.Port());
port_text.Format(TEXT("%d"), addr.Port());
port_field->SetWindowText(port_text);
}
}
}
6 changes: 3 additions & 3 deletions Lite/AnsiBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void CAnsiBar::OnBk()
mnu.CreatePopupMenu();
for (int i = 10;i < 18;i++)
{
mnu.AppendMenu(MF_OWNERDRAW, i, "");
mnu.AppendMenu(MF_OWNERDRAW, i, TEXT(""));
}
CRect rc;
::GetWindowRect(::GetDlgItem(m_hWnd, IDC_ANSIBAR_BK), rc);
Expand All @@ -67,7 +67,7 @@ void CAnsiBar::OnFg()
mnu.CreatePopupMenu();
for (int i = 10;i < 26;i++)
{
mnu.AppendMenu(MF_OWNERDRAW, i, "");
mnu.AppendMenu(MF_OWNERDRAW, i, TEXT(""));
}
CRect rc;
::GetWindowRect(::GetDlgItem(m_hWnd, IDC_ANSIBAR_FG), rc);
Expand Down Expand Up @@ -108,7 +108,7 @@ void CAnsiBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
if (GetRValue(clr) <= 128 && GetGValue(clr) <= 128 && GetBValue(clr) <= 128)
txtclr = 0xffffff;
dc.SetTextColor(txtclr);
char txt[5];
TCHAR txt[5];
dc.DrawEdge(&lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState&ODS_SELECTED ? EDGE_SUNKEN : EDGE_RAISED, BF_RECT);
::GetWindowText(lpDrawItemStruct->hwndItem, txt, 5);
dc.DrawText(txt, 4, &lpDrawItemStruct->rcItem, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
Expand Down
2 changes: 1 addition & 1 deletion Lite/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ CString GetIEPath()
HKEY hk = NULL;
// RegOpenKey( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE", &hk );
// RegQueryValue( hk, NULL, fpath.GetBuffer(_MAX_PATH), &len);
RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE", fpath.GetBuffer(_MAX_PATH), &len);
RegQueryValue(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE"), fpath.GetBuffer(_MAX_PATH), &len);
// RegCloseKey( hk );
fpath.ReleaseBuffer();
return fpath;
Expand Down
2 changes: 1 addition & 1 deletion Lite/AutoComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ int CAutoComplete::CompareItem(const void *p1, const void *p2)
int r = item1->strstrpos - item2->strstrpos;
if (0 != r)
return r;
return strcmp(m_pOpenedList->m_pSrc->GetAt(item1->strpos),
return _tcscmp(m_pOpenedList->m_pSrc->GetAt(item1->strpos),
m_pOpenedList->m_pSrc->GetAt(item2->strpos));
}

Expand Down
26 changes: 13 additions & 13 deletions Lite/AutoReplyPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void CAutoReplyPage::OnAdd()
msg.SetWindowText(NULL);
respond.SetWindowText(NULL);
protect.SetCheck(FALSE);
first.SetWindowText("1");
count.SetWindowText("1");
first.SetWindowText(TEXT("1"));
count.SetWindowText(TEXT("1"));
list.EnableWindow(FALSE);
}

Expand Down Expand Up @@ -197,20 +197,20 @@ void CAutoReplyPage::UpdateDisplay()
msg.SetWindowText(item->msg);
respond.SetPasswordChar(*LPCTSTR(item->respond) == '+' ? '*' : 0);
CString tmp = LPCTSTR(item->respond) + 1;
tmp.Replace("^M^J", "\r\n");
tmp.Replace("^M", "\r\n");
tmp.Replace(TEXT("^M^J"), TEXT("\r\n"));
tmp.Replace(TEXT("^M"), TEXT("\r\n"));
respond.SetWindowText(tmp);
protect.SetCheck(*LPCTSTR(item->respond) == '+');

char sfirst[8];
itoa(item->first, sfirst, 10);
TCHAR sfirst[8];
_itot(item->first, sfirst, 10);
first.SetWindowText(sfirst);
char scount[8];
TCHAR scount[8];
if (item->count == 0)
count.SetWindowText(NULL);
else
{
itoa(item->count, scount, 10);
_itot(item->count, scount, 10);
count.SetWindowText(scount);
}
}
Expand Down Expand Up @@ -247,21 +247,21 @@ void CAutoReplyPage::OnSave()
item->msg = tmp;

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

char sfirst[8];
TCHAR sfirst[8];
first.GetWindowText(sfirst, 8);
item->first = atoi(sfirst);
item->first = _tstoi(sfirst);
if (item->first < 1)
item->first = 1;
char scount[8];
TCHAR scount[8];
count.GetWindowText(scount, 8);
if (!*scount)
item->count = 0;
else
item->count = atoi(scount);
item->count = _tstoi(scount);

if (badd) //如果新增
i = list.AddString(item->msg);
Expand Down
16 changes: 8 additions & 8 deletions Lite/AutoUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static char THIS_FILE[]=__FILE__;
CAutoUpdater::CAutoUpdater()
{
// Initialize WinInet
hInternet = InternetOpen("AutoUpdateAgent", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
hInternet = InternetOpen(TEXT("AutoUpdateAgent"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
}

CAutoUpdater::~CAutoUpdater()
Expand Down Expand Up @@ -144,7 +144,7 @@ CAutoUpdater::ErrorType CAutoUpdater::CheckForUpdate()
// }

MessageBox(AfxGetMainWnd()->m_hWnd, LoadString(IDS_INSTALL_UPDATE), LoadString(IDS_PCMAN_CLOSE), MB_ICONINFORMATION|MB_OK);
if (!::ShellExecute(AfxGetMainWnd()->m_hWnd, "open", updateFileLocation, NULL, NULL,
if (!::ShellExecute(AfxGetMainWnd()->m_hWnd, TEXT("open"), updateFileLocation, NULL, NULL,
SW_SHOWNORMAL))
{
return UpdateNotComplete;
Expand Down Expand Up @@ -325,7 +325,7 @@ int CAutoUpdater::CompareVersions(CString ver1, CString ver2)
}

// Get version 1 to DWORDs
TCHAR *pToken = strtok(pVer1, _T("."));
TCHAR *pToken = _tcstok(pVer1, _T("."));
if (pToken == NULL)
{
return -21;
Expand All @@ -338,14 +338,14 @@ int CAutoUpdater::CompareVersions(CString ver1, CString ver2)
{
return -21; // Error in structure, too many parameters
}
wVer1[i] = atoi(pToken);
pToken = strtok(NULL, _T("."));
wVer1[i] = _tstoi(pToken);
pToken = _tcstok(NULL, _T("."));
i--;
}
ver1.ReleaseBuffer();

// Get version 2 to DWORDs
pToken = strtok(pVer2, _T("."));
pToken = _tcstok(pVer2, _T("."));
if (pToken == NULL)
{
return -22;
Expand All @@ -358,8 +358,8 @@ int CAutoUpdater::CompareVersions(CString ver1, CString ver2)
{
return -22; // Error in structure, too many parameters
}
wVer2[i] = atoi(pToken);
pToken = strtok(NULL, _T("."));
wVer2[i] = _tstoi(pToken);
pToken = _tcstok(NULL, _T("."));
i--;
}
ver2.ReleaseBuffer();
Expand Down
4 changes: 2 additions & 2 deletions Lite/AutoUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#endif

#define LOCATION_UPDATE_FILE_CHECK _T(UPDATE_FILE)
static UINT NEAR WM_COMMIT_UPDATE = RegisterWindowMessage("COMMIT_UPDATE");
static UINT NEAR WM_DOWNLOAD_UPDATE_COMPLETE = RegisterWindowMessage("DOWNLOAD_UPDATE_COMPLETE");
static UINT NEAR WM_COMMIT_UPDATE = RegisterWindowMessage(TEXT("COMMIT_UPDATE"));
static UINT NEAR WM_DOWNLOAD_UPDATE_COMPLETE = RegisterWindowMessage(TEXT("DOWNLOAD_UPDATE_COMPLETE"));

class CAutoUpdater
{
Expand Down
2 changes: 1 addition & 1 deletion Lite/BBSHyperLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void CBBSHyperLink::OpenURL(LPCTSTR url)
((CMainFrame*)AfxGetApp()->m_pMainWnd)->view.ConnectWeb(CAddress(url), AppConfig.link_autoswitch);
else
#endif
::ShellExecute(AfxGetMainWnd()->m_hWnd, "open", path, param, NULL,
::ShellExecute(AfxGetMainWnd()->m_hWnd, TEXT("open"), path, param, NULL,
AppConfig.link_autoswitch ? SW_SHOWMAXIMIZED : SW_SHOWMINIMIZED);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lite/Clipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CClipboard

inline BOOL CClipboard::SetText(HWND owner, LPCTSTR str)
{
return SetText(owner, str, strlen(str));
return SetText(owner, str, _tcslen(str));
}

inline BOOL CClipboard::SetTextW(HWND owner, const wchar_t* str)
Expand Down
2 changes: 1 addition & 1 deletion Lite/ColorConfigDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void CColorConfigDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
COLORREF clr = colormap[nIDCtl-5];
CDC dc;
char txt[10];
TCHAR txt[10];
dc.Attach(lpDrawItemStruct->hDC);
CRect rc;
::GetClientRect(lpDrawItemStruct->hwndItem, &rc);
Expand Down
7 changes: 4 additions & 3 deletions Lite/ConfigFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ bool CConfigFile::DoSave(ConfigTable table)
CString str, esc_str;
for (; table->name; table++)
{
str.Format("[%s]\r\n", table->name);
str.Format(TEXT("[%s]\r\n"), table->name);
file.Write(LPCTSTR(str), str.GetLength());

if (table->type == VT_CUSTOM_SECT)
Expand All @@ -209,7 +209,8 @@ bool CConfigFile::DoSave(ConfigTable table)
else
cur_sect = (ConfigEntry*)table->data;

char strval[64]; const char* pstrval;
char strval[64];
const char* pstrval;
for (; cur_sect->name; cur_sect++)
{
pstrval = strval;
Expand Down Expand Up @@ -256,7 +257,7 @@ bool CConfigFile::DoSave(ConfigTable table)
}
break;
}
str.Format("%s=%s\r\n", cur_sect->name, pstrval);
str.Format(TEXT("%s=%s\r\n"), cur_sect->name, pstrval);
file.Write(LPCTSTR(str), str.GetLength());
}
file.Write("\r\n", 2);
Expand Down
8 changes: 4 additions & 4 deletions Lite/ConnectPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void CConnectPage::InitWithAddress(const CString& addr)
int pos = address.ReverseFind(':');
if (pos != -1)
{
port = (unsigned short)atoi(address.Mid(pos + 1));
port = (unsigned short)_tstoi(address.Mid(pos + 1));
address = address.Left(pos);
}
}
Expand All @@ -53,7 +53,7 @@ CString CConnectPage::GetFormattedAddress() const
if (port == 23 || port <= 0)
return address;
CString buf;
buf.Format("%s:%d", LPCTSTR(address), port);
buf.Format(TEXT("%s:%d"), LPCTSTR(address), port);
return buf;
}

Expand Down Expand Up @@ -117,7 +117,7 @@ void CConnectPage::OnAddressChanged()
if (addr.IsValid())
{
CString port_text;
port_text.Format("%d", addr.Port());
port_text.Format(TEXT("%d"), addr.Port());
port_field->SetWindowText(port_text);
}
}
}
2 changes: 1 addition & 1 deletion Lite/CtrlEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ LRESULT CCtrlEdit::OnPaste(WPARAM w, LPARAM l)
if (strstr(data, "\x1b[")) //如果含有色彩控制碼
{
CString tmp = data;
tmp.Replace("\x1b[", "^[[");
tmp.Replace(TEXT("\x1b["), TEXT("^[["));
ReplaceSel(tmp, FALSE);
CStringDlg* pdlg = (CStringDlg*)GetParent();
if (pdlg)
Expand Down
Loading

0 comments on commit 0337f12

Please sign in to comment.