Android platform version and device fragmentation is very serious, so porting from the Win32 platform to the Android platform will have a lot of problems, the following is a summary of our migration from the Win32 platform to the Android platform encountered some problems.
In the Android platform Chinese garbled is not a problem, or on the Android platform should not appear in Chinese garbled. This problem is based on the fact that we have developed Android applications under Windows. By default, the Windows Chinese environment is GBK encoded, the source program file HelloWorldScene.cpp encoding by default is also GBK if there is a Chinese input in the source code, such as the following code:
[HTML] view Plaincopy
void Helloworld::onclickmenu1 (object* psender)
{
Notedao::initdb ();
Notedao::create ("2008-08-16 10:01:02", "Initialize data.") ");
}
void Helloworld::onclickmenu2 (object* psender)
{
String currenttime = myutility:: GetCurrentTime ();
Log ("%s", Currenttime.c_str ());
Notedao::create (CurrentTime, "Welcome to MyNote. ");
}
This program compiled after the Chinese encoding is still GBK, because the Android platform uses the encoding is UTF-8, when they on the Android platform through the log functions or tags, such as control output will be garbled.
The solution is very simple, we just need to save the HelloWorldScene.cpp file as UTF-8, with the text editing tools such as Notepad and then save as UTF-8, if it is in the Visual Studio tool can choose the menu file → advanced save options, In the pop-up dialog box, select Encode as Unicode (UTF-8 with signature) and click the OK button to save.
Advanced Save Options
We only need to have Chinese characters in the file (including H and CPP files), using the Save as UTF-8 character set above, other files can not be considered. It is necessary to remember that the default standard in the character set is UTF-8 on Android and iOS platforms.
For more information, please pay attention to the first Cocos2d-x 3.2 Edition book "Cocos2d-x: C + + volume"
Book Exchange Discussion website: http://www.cocoagame.net
For more exciting video courses, please follow Cocos class: Http://v.51work6.com
Welcome to join Cocos2d-x Technical discussion group: 257760386
Welcome to Luxgen iOS Classroom public Platform
Cocos porting to Android some problems-Chinese garbled problem