From d5baf212f45c3926ffec3bccad77ca4dd0751d23 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 21 Oct 2010 05:34:01 +0300 Subject: using utf8<->utf16 on poor c++ instead of miranda api (can solve some issues with badly encoded messages, testing needed) --- main.cpp | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 70709e0..27ed44e 100644 --- a/main.cpp +++ b/main.cpp @@ -110,31 +110,31 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM break; stop = p; p2 = out.find("/", p) - 1; - TCHAR *tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str()); + TCHAR *tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p)).c_str()); item.pszText = tmp; iRow = ListView_InsertItem(hwndList, &item); ListView_SetItemText(hwndList, iRow, 4, tmp); mir_free(tmp); p2+=2; p = out.find(" ", p2); - tmp = mir_utf8decodeW(out.substr(p2,p-p2).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p2,p-p2)).c_str()); ListView_SetItemText(hwndList, iRow, 0, tmp); mir_free(tmp); p = out.find("uid ", p); p2 = out.find_first_not_of(" ", p+5); p = out.find("<", p2); - tmp = mir_utf8decodeW(out.substr(p2,p-p2).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p2,p-p2)).c_str()); ListView_SetItemText(hwndList, iRow, 2, tmp); mir_free(tmp); p++; p2 = out.find(">", p); - tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p)).c_str()); ListView_SetItemText(hwndList, iRow, 1, tmp); mir_free(tmp); p = out.find("ssb ", p2) + 6; p = out.find(" ", p) + 1; p2 = out.find("\n", p); - tmp = mir_utf8decodeW(out.substr(p,p2-p-1).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p-1)).c_str()); ListView_SetItemText(hwndList, iRow, 3, tmp); mir_free(tmp); ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);// not sure about this @@ -276,31 +276,31 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM break; stop = p; p2 = out.find("/", p) - 1; - TCHAR *tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str()); + TCHAR *tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p)).c_str()); item.pszText = tmp; iRow = ListView_InsertItem(hwndList, &item); ListView_SetItemText(hwndList, iRow, 4, tmp); mir_free(tmp); p2+=2; p = out.find(" ", p2); - tmp = mir_utf8decodeW(out.substr(p2,p-p2).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p2,p-p2)).c_str()); ListView_SetItemText(hwndList, iRow, 0, tmp); mir_free(tmp); p = out.find("uid ", p); p2 = out.find_first_not_of(" ", p+5); p = out.find("<", p2); - tmp = mir_utf8decodeW(out.substr(p2,p-p2).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p2,p-p2)).c_str()); ListView_SetItemText(hwndList, iRow, 2, tmp); mir_free(tmp); p++; p2 = out.find(">", p); - tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p)).c_str()); ListView_SetItemText(hwndList, iRow, 1, tmp); mir_free(tmp); p = out.find("ssb ", p2) + 6; p = out.find(" ", p) + 1; p2 = out.find("\n", p); - tmp = mir_utf8decodeW(out.substr(p,p2-p-1).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p-1)).c_str()); ListView_SetItemText(hwndList, iRow, 3, tmp); mir_free(tmp); ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);// not sure about this @@ -853,7 +853,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, if(tmp[0]) { f<<"Passphrase: "; - tmp2 = mir_utf8encodeW(tmp); + tmp2 = mir_strdup(toUTF8(tmp).c_str()); f<", p); - tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p)).c_str()); ListView_SetItemText(hwndList_g, iRow, 1, tmp); mir_free(tmp); p = out.find("ssb ", p2) + 6; p = out.find(" ", p) + 1; p2 = out.find("\n", p); - tmp = mir_utf8decodeW(out.substr(p,p2-p-1).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p-1)).c_str()); ListView_SetItemText(hwndList_g, iRow, 3, tmp); mir_free(tmp); ListView_SetColumnWidth(hwndList_g, 0, LVSCW_AUTOSIZE);// not sure about this @@ -1117,31 +1117,31 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam, break; stop = p; p2 = out.find("/", p) - 1; - TCHAR *tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str()); + TCHAR *tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p)).c_str()); item.pszText = tmp; iRow = ListView_InsertItem(hwndList, &item); ListView_SetItemText(hwndList, iRow, 4, tmp); mir_free(tmp); p2+=2; p = out.find(" ", p2); - tmp = mir_utf8decodeW(out.substr(p2,p-p2).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p2,p-p2)).c_str()); ListView_SetItemText(hwndList, iRow, 0, tmp); mir_free(tmp); p = out.find("uid ", p); p2 = out.find_first_not_of(" ", p+5); p = out.find("<", p2); - tmp = mir_utf8decodeW(out.substr(p2,p-p2).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p2,p-p2)).c_str()); ListView_SetItemText(hwndList, iRow, 2, tmp); mir_free(tmp); p++; p2 = out.find(">", p); - tmp = mir_utf8decodeW(out.substr(p,p2-p).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p)).c_str()); ListView_SetItemText(hwndList, iRow, 1, tmp); mir_free(tmp); p = out.find("sub ", p2) + 6; p = out.find(" ", p) + 1; p2 = out.find("\n", p); - tmp = mir_utf8decodeW(out.substr(p,p2-p-1).c_str()); + tmp = mir_wstrdup(toUTF16(out.substr(p,p2-p-1)).c_str()); ListView_SetItemText(hwndList, iRow, 3, tmp); mir_free(tmp); ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);// not sure about this @@ -1676,7 +1676,7 @@ void ImportKey() DBDeleteContactSetting(hContact, szGPGModuleName, "bAlwatsTrust"); } } - ptmp = mir_utf8decodeW(output.c_str()); + ptmp = mir_wstrdup(toUTF16(output).c_str()); MessageBox(0, ptmp, _T(""), MB_OK); mir_free(ptmp); DeleteFile(tmp2); -- cgit v1.2.3