Deal with possible BOM (dont assume BOM always there).

This commit is contained in:
unitrunker 2018-01-22 14:52:10 -06:00
parent f2baba7c77
commit bf0228487b

View File

@ -983,8 +983,8 @@ namespace detail
nana::detail::charset_conv charset(NANA_UNICODE, "UTF-8");
const std::string& str = charset.charset(std::string(keybuf, keybuf + len));
charbuf = reinterpret_cast<const wchar_t*>(str.c_str()) + 1;
len = str.size() / sizeof(wchar_t) - 1;
charbuf = reinterpret_cast<const wchar_t*>(str.c_str());
len = str.size() / sizeof(wchar_t);
for(int i = 0; i < len; ++i)
{
@ -992,6 +992,9 @@ namespace detail
arg.ignore = false;
arg.key = charbuf[i];
// ignore Unicode BOM (it may or may not appear)
if (arg.key == 0xFEFF) continue;
//Only accept tab when it is not ignored.
if ((keyboard::tab == arg.key) && root_runtime->condition.ignore_tab)
continue;