wctomb(NULL, _) returns "nonzero if the encoding has nontrivial shift state, or zero if the encoding is stateless."
I assume the intentation was to get the size of the target buffer.
Use MB_CUR_MAX for this.
if (valid_kcode(Key)) {
m_name = KeyNames[Key];
} else {
- size_t maxlen = wctomb(NULL, Char);
- m_name.resize(maxlen+1, '\0');
+ m_name.resize(MB_CUR_MAX+1, '\0');
int written = wctomb(&m_name[0], Char);
assert (written >= 0 && "unexpected multibyte character");
}