replace char: fix unicode handling

This commit is contained in:
Maxime Coste 2013-01-17 18:47:53 +01:00
parent 44ca4d23de
commit 9c2bbe218b
3 changed files with 9 additions and 9 deletions

View File

@ -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:

View File

@ -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);
});
}

View File

@ -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