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);
WideCharToMultiByte is win32 function.
so can’t compile in android gcc enviroment.
then how to convert UTF-8 character string? or,
is cocos2d-x support to unicode TCHAR wchar_t etc…?
thanks.