Skip to content

Commit c420b81

Browse files
author
Kirill Belousov
committed
Fixes history behavior with non-english characters
1 parent e026cc6 commit c420b81

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/ui.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <spdlog/spdlog.h>
99
#include <string>
10+
#include <wx/string.h>
1011

1112
MainFrame::MainFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title) {
1213
m_panel = new wxPanel(this, wxID_ANY);
@@ -109,23 +110,24 @@ void MainFrame::OnEnterPress(wxCommandEvent& event) {
109110
if (m_messageField->IsEmpty()) {
110111
return;
111112
}
112-
auto text = m_messageField->GetValue();
113-
if (!Speech::GetInstance().speak(text.ToUTF8().data())) {
113+
wxString messageText = m_messageField->GetValue();
114+
std::string text = std::string(messageText.utf8_str());
115+
if (!Speech::GetInstance().speak(text.c_str())) {
114116
wxMessageBox("This voice either does not work with the program or crashes it. Please select another voice.",
115117
"Error! The selected SAPI voice is not supported.", 5L, m_panel);
116118
}
117-
g_HistoryStorage.push(text.ToStdString());
119+
g_HistoryStorage.push(text);
118120
m_messageField->Clear();
119121
}
120122

121123
void MainFrame::OnMessageFieldKeyDown(wxKeyEvent& event) {
122-
auto text = m_messageField->GetValue().ToStdString();
124+
std::string text = std::string(m_messageField->GetValue().utf8_str());
123125
switch (event.GetKeyCode()) {
124126
case WXK_UP:
125-
m_messageField->SetValue(g_HistoryStorage.getPreviousByText(text));
127+
m_messageField->SetValue(wxString::FromUTF8(g_HistoryStorage.getPreviousByText(text)));
126128
break;
127129
case WXK_DOWN:
128-
m_messageField->SetValue(g_HistoryStorage.getNextByText(text));
130+
m_messageField->SetValue(wxString::FromUTF8(g_HistoryStorage.getNextByText(text)));
129131
break;
130132
}
131133
event.Skip();

0 commit comments

Comments
 (0)