From 9c2bbe218b32d6ce44be976a7b14eb0908a102e0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 17 Jan 2013 18:47:53 +0100 Subject: [PATCH] replace char: fix unicode handling --- src/input_handler.cc | 8 -------- src/main.cc | 2 +- src/string.hh | 8 ++++++++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/input_handler.cc b/src/input_handler.cc index ae14bdc0..dc9392c1 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -61,14 +61,6 @@ private: int m_count = 0; }; -String codepoint_to_str(Codepoint cp) -{ - std::string str; - auto it = back_inserter(str); - utf8::dump(it, cp); - return String(str); -} - class LineEditor { public: diff --git a/src/main.cc b/src/main.cc index 585dbb8b..cc87a401 100644 --- a/src/main.cc +++ b/src/main.cc @@ -102,7 +102,7 @@ void do_replace_with_char(Context& context) SelectionList sels = editor.selections(); auto restore_sels = on_scope_end([&]{ editor.select(std::move(sels)); }); editor.multi_select(std::bind(select_all_matches, _1, ".")); - editor.insert(String() + key.key, InsertMode::Replace); + editor.insert(codepoint_to_str(key.key), InsertMode::Replace); }); } diff --git a/src/string.hh b/src/string.hh index ef30195d..773a6cbc 100644 --- a/src/string.hh +++ b/src/string.hh @@ -101,6 +101,14 @@ inline String operator"" _str(const char* str, size_t) return String(str); } +inline String codepoint_to_str(Codepoint cp) +{ + std::string str; + auto it = back_inserter(str); + utf8::dump(it, cp); + return String(str); +} + } namespace std