About CCIMEDispatcher Unicode

About CCIMEDispatcher Unicode
0.0 0



There are some problems with the TextInputTest sample code : when i inputted chinese words into it

when i inputted chinese words , it look like this :
two words “你你” ~right

and two words“我我”
just show one~no good

and input “你5”
just show one~no good

Can use CCLabelTTF to Perform Unicode??

cocos2d version 0.99.5-x-0.8.4
cocos2d settings is unicode.
my project settings is unicode.

0.jpg (56.2 KB)

55.jpg (120.1 KB)

ok.jpg (54.1 KB)

2.jpg (55.8 KB)


CCLabelTTF only supports UTF8. Chinese characters in UTF8 format is better supported on iOS & Android.
If you want to use unicode in the game, please convert it before input to CCLabelTTF.



Yes, i convert it.

std::string utf8_encode(const std::wstring &wstr)
    int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
    std::string strTo( size_needed, 0 );
    WideCharToMultiByte                  (CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
    return strTo;
std::wstring ws(L"我6我");
std::string str=utf8_encode(ws);
CCLabelTTF* label = CCLabelTTF::labelWithString(str.c_str(), "Arial", 24);

Inputted L“你6你” and L“我6我”

Use CCTexture2D to create FontLabel by CCLabelTTF.

    CCImage image;   
    if (! image.initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize))
        return false;

i think it may have some kind of problems.
maybe image size~
it calculate the font width very strange.
inputted “你” that printed width:36
inputted “你你” that printed width:58
inputted “我” that printed width:22
inputted “我我” that printed width:44