1

I request a web page using CCHttpRequest then when I print the received response with CCString I can see turkish characters without any problems but when I assign the received response using std::string and print in CCLog strange characters come up. How can I fix this?

std::vector<char> *buffer = response->getResponseData();

char jenny [buffer->size()];

for (unsigned int i = 0; i < buffer->size(); i++)
{
    jenny[i] = (*buffer)[i];
}


CCString* uStr = CCString::createWithContentsOfFile(jenny);

string wStr(jenny);

CCLog("%ls", &wStr);

CCString Response : Get data from file(< ?xml version="1.0" encoding="utf-8"?> < string xmlns="http://tempuri.org/" > Gönderildi < / string >

string CCLog Response : ����k�4p�

Andriy
  • 2,767
  • 2
  • 21
  • 29
onder
  • 795
  • 3
  • 14
  • 32

2 Answers2

1

Do you just want to print the values in CCLOG or do you want to actually display them in the CCLabel?

If you want to display them in CCLabel then you can do in the following way:

  1. Store the values in std::string
  2. When you are assigning it to label then use c_str() method to retrieve the value.

Example:

std::string friendID            = friendDetails->getFBID();
CCLabelTTF *friendNameLabel = CCLabelTTF::create(friendName.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
friendNameLabel->setString(friendName.c_str());

IMO, this should work perfectly fine. I am using them in one of my library in which I am getting the data from Facebook and using it in the game.

Here is the code link where I am displaying the names of the Facebook Friends of the FB user.

codesnooker
  • 1,191
  • 10
  • 19
0

Try setting locale, here is a link to provide you help with

Why doesn't printf format unicode parameters?

Community
  • 1
  • 1
aajiwani
  • 121
  • 6