add a namespace nana::utf for UTF-8 character processing

This commit is contained in:
Jinhao
2016-01-01 12:30:18 +08:00
parent a42ebe19b4
commit 0a4f04267e
4 changed files with 199 additions and 2 deletions

View File

@@ -348,7 +348,7 @@ namespace API
text.erase(pos, 1);
if(shortkey == 0 && pos < text.length())
{
shortkey = text.at(pos);
shortkey = utf::char_at(text.c_str() + pos, 0, nullptr);
if(shortkey == '&') //This indicates the text contains "&&", it means the symbol have to be ignored.
shortkey = 0;
else if(skpos)

View File

@@ -258,7 +258,9 @@ namespace nana{ namespace drawerbase
if(shortkey)
{
unsigned off_w = (shortkey_pos ? graph.text_extent_size(mbstr.c_str(), static_cast<unsigned>(shortkey_pos)).width : 0);
nana::size shortkey_size = graph.text_extent_size(to_wstring(mbstr.c_str() + shortkey_pos), 1);
wchar_t keystr[2] = {nana::utf::char_at(mbstr.c_str() + shortkey_pos, 0, 0), 0};
auto shortkey_size = graph.text_extent_size(keystr, 1);
unsigned ascent, descent, inleading;
graph.text_metrics(ascent, descent, inleading);