首页 > 代码库 > Cocos2dx3.0 TextField 输入中文的问题

Cocos2dx3.0 TextField 输入中文的问题

一开始无法输入中文, 显示出来的是乱码, 修改一个函数, 下面是修改过后的代码

void GLView::onGLFWCharCallback(GLFWwindow *window, unsigned int character){    if (character < 128)    {        IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*)&character, 1);    }    else    {        long items_read = 0;        long items_write = 0;        char* buf = cc_utf16_to_utf8((unsigned short*)&character, 1, &items_read, &items_write);        IMEDispatcher::sharedDispatcher()->dispatchInsertText(buf, items_write);        free(buf);    }    }

参考文档:
http://blog.csdn.net/xie1xiao1jun/article/details/38711849
http://www.cocoachina.com/bbs/read.php?tid=166857

Cocos2dx3.0 TextField 输入中文的问题