修改cocos2d-x-3.xcocos2dplatformdesktopCCGLView.cpp GLView::onGLFWCharCallback方法
//原来的方法如下:
void GLView::onGLFWCharCallback(GLFWwindow *window, unsigned int character)
{
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*)&character, 1);
}
//修改后的方法如下:
void GLView::onGLFWCharCallback(GLFWwindow *window, unsigned int character)
{
if (character < 128)
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*)&character, 1);
else
{
char szUtf8[8] = { 0 };
int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)&character, 1, szUtf8, sizeof(szUtf8), NULL, NULL);
IMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen);
}
}