From d05f7096cd384679e9dcab92a6efc81c68977628 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 18 Feb 2019 13:30:21 +0300 Subject: utf8 wrappers for CCtrlBase::GetText --- src/mir_core/src/CCtrlBase.cpp | 16 ++++++++++++++-- src/mir_core/src/mir_core.def | 6 ++++-- src/mir_core/src/mir_core64.def | 6 ++++-- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mir_core/src/CCtrlBase.cpp b/src/mir_core/src/CCtrlBase.cpp index 74dac95380..609804e390 100644 --- a/src/mir_core/src/CCtrlBase.cpp +++ b/src/mir_core/src/CCtrlBase.cpp @@ -144,20 +144,32 @@ char* CCtrlBase::GetTextA() return result; } -wchar_t* CCtrlBase::GetText(wchar_t *buf, int size) +char* CCtrlBase::GetTextU() +{ + return mir_utf8encodeW(ptrW(GetText())); +} + +wchar_t* CCtrlBase::GetText(wchar_t *buf, size_t size) { GetWindowTextW(m_hwnd, buf, size); buf[size - 1] = 0; return buf; } -char* CCtrlBase::GetTextA(char *buf, int size) +char* CCtrlBase::GetTextA(char *buf, size_t size) { GetWindowTextA(m_hwnd, buf, size); buf[size - 1] = 0; return buf; } +char* CCtrlBase::GetTextU(char *buf, size_t size) +{ + ptrW wszText(GetText()); + strncpy_s(buf, size, T2Utf(wszText), _TRUNCATE); + return buf; +} + int CCtrlBase::GetInt() { int length = GetWindowTextLengthW(m_hwnd) + 1; diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index a70c6493e0..0ce94238f5 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -676,9 +676,9 @@ mir_wstrcmpi @280 ?GetState@CCtrlCheck@@QAEHXZ @862 NONAME ?GetStringWidth@CCtrlListView@@QAEHPBD@Z @863 NONAME ?GetSubItemRect@CCtrlListView@@QAEHHHHPAUtagRECT@@@Z @864 NONAME -?GetText@CCtrlBase@@QAEPA_WPA_WH@Z @865 NONAME +?GetText@CCtrlBase@@QAEPA_WPA_WI@Z @865 NONAME ?GetText@CCtrlBase@@QAEPA_WXZ @866 NONAME -?GetTextA@CCtrlBase@@QAEPADPADH@Z @867 NONAME +?GetTextA@CCtrlBase@@QAEPADPADI@Z @867 NONAME ?GetTextA@CCtrlBase@@QAEPADXZ @868 NONAME ?GetTextBkColor@CCtrlListView@@QAEKXZ @869 NONAME ?GetTextColor@CCtrlListView@@QAEKXZ @870 NONAME @@ -1416,3 +1416,5 @@ db_event_edit @1268 ??AXMLConstHandle@tinyxml2@@QBE?BV01@PBD@Z @1629 NONAME ??AXMLHandle@tinyxml2@@QAE?AV01@PBD@Z @1630 NONAME db_get_utfa @1631 +?GetTextU@CCtrlBase@@QAEPADPADI@Z @1632 NONAME +?GetTextU@CCtrlBase@@QAEPADXZ @1633 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index d4dced17cf..f508deb72d 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -676,9 +676,9 @@ mir_wstrcmpi @280 ?GetState@CCtrlCheck@@QEAAHXZ @862 NONAME ?GetStringWidth@CCtrlListView@@QEAAHPEBD@Z @863 NONAME ?GetSubItemRect@CCtrlListView@@QEAAHHHHPEAUtagRECT@@@Z @864 NONAME -?GetText@CCtrlBase@@QEAAPEA_WPEA_WH@Z @865 NONAME +?GetText@CCtrlBase@@QEAAPEA_WPEA_W_K@Z @865 NONAME ?GetText@CCtrlBase@@QEAAPEA_WXZ @866 NONAME -?GetTextA@CCtrlBase@@QEAAPEADPEADH@Z @867 NONAME +?GetTextA@CCtrlBase@@QEAAPEADPEAD_K@Z @867 NONAME ?GetTextA@CCtrlBase@@QEAAPEADXZ @868 NONAME ?GetTextBkColor@CCtrlListView@@QEAAKXZ @869 NONAME ?GetTextColor@CCtrlListView@@QEAAKXZ @870 NONAME @@ -1416,3 +1416,5 @@ db_event_edit @1268 ??AXMLConstHandle@tinyxml2@@QEBA?BV01@PEBD@Z @1629 NONAME ??AXMLHandle@tinyxml2@@QEAA?AV01@PEBD@Z @1630 NONAME db_get_utfa @1631 +?GetTextU@CCtrlBase@@QEAAPEADPEAD_K@Z @1632 NONAME +?GetTextU@CCtrlBase@@QEAAPEADXZ @1633 NONAME -- cgit v1.2.3