cocos2d version: cocos2d-2.0-x-2.0.3
after the following code, data from json file now stored in jsonBuffer of char type.
std::string fullpath4json = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("p.json"); unsigned long bufferSize; char *jsonBuffer = (char *)CCFileUtils::sharedFileUtils()->getFileData(fullpath4json.c_str(), "r", &bufferSize); jsonBuffer[bufferSize] = '\0';
I use libjson to do the parsing, and the unicode feature is set on, so json_char is equivalent to wchar_t.
json_char *pJSON = new json_char[bufferSize+1]; mbstowcs(pJSON, jsonBuffer, bufferSize+1);
I validated the data with json_is_valid from libjson, it returned 0 after the conversion, while it returned 1 before, so it’s the issue about conversion from char to wchar_t.
Is mbstowcs() function supported by ndk? if it’s not, any other way to do the conversion?