CCUserDefault on winRT. File not exist

CCUserDefault on winRT. File not exist
0.0 0


i try to run UserDefaultTeest from TestCppProject and have some problems:
dubug message in output window:

Get data from file(C:\Users\;5:A59\AppData\Local\Packages\E4A2CC60-D3B0-43D5-B514-53CF589CEDEB_m9k0q4hvj1fvp\LocalState\UserDefault.xml) failed!

and function CCUserDefault::sharedUserDefault()->isXMLFileExist(); return false

Whats wrong?


still not working


Hi Argas, I tested UserDefaultTest.cpp, and it results ok and not faced with your problem. But I guessed your file path was wrong, there is a “;5:A59” in your path and I guess the system couldn’t recognized it. When I created a folder, couldn;t use “:” in path. Thanks.


I have exactly the same problem - and the reason is cyrillic windows username. It becomes ugly (for example - “;5:A59” instead of something like “Артём”) after convertion in CCWinRTUtils.cpp in method
std::string PlatformStringToString(Platform::String^ s)

So I’m not able to use CCUserDefault::sharedUserDefault() at all, application fails. Any ideas on this?


This is a cocos2d-x bug. It doesn’t handle non-ASCII usernames properly. I filed a bug report and noticed another person also did but it seems to be low priority (odd considering this project originated in China). You are lucky your app doesn’t crash and burn like mine did. To fix this, you need to edit the “PlatformStringToString” function inside of CCWinRTUtils.cpp. Here is mine

std::string PlatformStringToString(Platform::String^ s) {
    return CCUnicodeToUtf8(s->Data());

Also you need to get rid of all fopen usage and replace it with _wfopen. For example in getFileData() in CCWinRTFileUtils.cpp

std::string fullPath = fullPathForFilename(pszFileName);
wstring wfullPath = CCUtf8ToUnicode(, fullPath.size());
wstring wpszMode = CCUtf8ToUnicode(pszMode, strlen(pszMode));
FILE *fp = _wfopen(wfullPath.c_str(), wpszMode.c_str());

CCUserDefault on winRT, File not exist