diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-07 17:15:48 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-07 17:15:48 +0200 |
commit | cd94bfc187d6a716f00d218e514409d8e65603c4 (patch) | |
tree | 80c88c145af78acf3f1b440963693b1a93cbd887 /src/SearchBar.cpp | |
parent | ca0e381e2a248170f71c236a5070ce349f0206ea (diff) |
Matrix: fix posting messages with non-ascii characters
Diffstat (limited to 'src/SearchBar.cpp')
-rw-r--r-- | src/SearchBar.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp index fa81c61..f489779 100644 --- a/src/SearchBar.cpp +++ b/src/SearchBar.cpp @@ -91,15 +91,19 @@ namespace QuickMedia { sf::Int32 elapsed_time = time_since_search_update.getElapsedTime().asMilliseconds(); if(updated_search && elapsed_time >= text_autosearch_delay) { updated_search = false; - sf::String str = text.getString(); + auto u8 = text.getString().toUtf8(); + std::string *u8_str = (std::string*)&u8; if(show_placeholder) - str.clear(); + u8_str->clear(); if(onTextUpdateCallback) - onTextUpdateCallback(str); + onTextUpdateCallback(*u8_str); } else if(updated_autocomplete && elapsed_time >= autocomplete_search_delay) { updated_autocomplete = false; - if(!show_placeholder && onAutocompleteRequestCallback) - onAutocompleteRequestCallback(text.getString()); + if(!show_placeholder && onAutocompleteRequestCallback) { + auto u8 = text.getString().toUtf8(); + std::string *u8_str = (std::string*)&u8; + onAutocompleteRequestCallback(*u8_str); + } } } @@ -165,10 +169,11 @@ namespace QuickMedia { } else if(codepoint == 13) { // Return bool clear_search = true; if(onTextSubmitCallback) { + auto u8 = text.getString().toUtf8(); + std::string *u8_str = (std::string*)&u8; if(show_placeholder) - clear_search = onTextSubmitCallback(""); - else - clear_search = onTextSubmitCallback(text.getString()); + u8_str->clear(); + clear_search = onTextSubmitCallback(*u8_str); } if(clear_search) |