Cocos2d-x Chinese garbled Problem

Source: Internet
Author: User

Engaged in a cocos2d-x of the Chinese display problem, in fact, because the cocos2d-x was originally built in unicode encoding format, but because VS2012 GBK encoding and it does not match, it also does not support Chinese (not supported currently), so garbled characters are generated when the running program contains Chinese characters. Google found a solution to this problem. We can use android to deal with it. Write an XML file in UTF-8 format. Be sure to put it in the Resource Directory. Otherwise, it cannot be found.

<Dict> <key> press1 </key> <string> press the button </string> <key> press2 </key> <string> press the button to move </string> <key> cancel1 </key> <string> release button </string> <key> cancel2 </key> <string> unclick </string> </dict>

 

Then, take the corresponding value as needed:
/** Use Chinese in the cocos2d-x ** // use CCDictionary to read xml CCDictionary * strings = CCDictionary: createWithContentsOfFile ("fonts/string. xml "); const char * press1 = (CCString *) strings-> objectForKey (" press1 ")-> getCString (); const char * press2 = (CCString *) strings-> objectForKey ("press2")-> getCString (); const char * cancel1 = (CCString *) strings-> objectForKey ("cancel1 ")) -> getCString (); const char * cancel2 = (CCString *) strings-> objectForKey ("cancel2")-> getCString ();

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.