scoreboard service: user name in chinese characters

0 votes

Hi

I am using APP42 SDK v_1.2.2 for cocos2dx 2.2.3

Right now I am only saving user score by calling SaveUserScore and getting scores by calling GetTopRankings.

When calling SaveUserScore, the userName is in Chinese characters. From SaveUserScore's callback function, the chinese characters can still be correctly shown. But When I call GetTopRankings, the chinese userNames all become question marks.

Can anybody show me how to solve this problem? Thanks  a lot.

asked Jul 6, 2014 in App42 Cloud API-BaaS by lnimi (10 points)

1 Answer

0 votes

Hi,

To support languages other than English, you can encode your inputs with base64 encoding before calling the APIs.

For example:

For calling SaveUserScore

ScoreBoardService *scoreBoardService = App42API::BuildScoreBoardService();

int score = 400;

string userName = "汉语";

string userN = base64_encode((unsigned char const*)userName.c_str(), userName.length());

scoreBoardService->SaveUserScore(gameName, userN.c_str(), score, this, app42callfuncND_selector(TestScoreboardService::onScoreBoardRequestCompleted));

When you receive response

string userName = base64_decode(app42Score->getUserName());

The encoding and decoding methods are available in the SDK in class "app42base64.h" but you need to include this class where you want to use these methods, or you can use the base64 class provided by Cocos2d-X.

I hope it will help.

Thanks.

answered Jul 7, 2014 by rajeev.etc (1,660 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...