Fix charset process in glfwCharCallback

This commit is contained in:
halx99 2022-12-18 11:52:57 +08:00
parent d79156d728
commit 2e4324c363
1 changed files with 3 additions and 5 deletions

View File

@ -1024,13 +1024,11 @@ void GLViewImpl::onGLFWKeyCallback(GLFWwindow* /*window*/, int key, int /*scanco
} }
} }
void GLViewImpl::onGLFWCharCallback(GLFWwindow* /*window*/, unsigned int character) void GLViewImpl::onGLFWCharCallback(GLFWwindow* /*window*/, unsigned int charCode)
{ {
char16_t wcharString[2] = {(char16_t)character, 0};
std::string utf8String; std::string utf8String;
StringUtils::UTF32ToUTF8(std::u32string_view{(char32_t*)&charCode, (size_t)1}, utf8String);
StringUtils::UTF16ToUTF8(wcharString, utf8String); static std::unordered_set<std::string_view> controlUnicode = {
static std::set<std::string> controlUnicode = {
"\xEF\x9C\x80", // up "\xEF\x9C\x80", // up
"\xEF\x9C\x81", // down "\xEF\x9C\x81", // down
"\xEF\x9C\x82", // left "\xEF\x9C\x82", // left