Getwritablepath's character problem

Getwritablepath's character problem
0

#1
            string      fileData    = FileUtils::getInstance()->getWritablePath() + "setting.dat";
            FILE*		pFile		= fopen(fileData.c_str(), "r");

I using getWritablePath like this.
but on windows, if computer’s username is not alphabat, like japanese, chinese, korean, pFile is NULL
because of string’s character is broken.
how can I fix this problem?
I saved this code by signed utf-8(code 65001).


#2

Use cocos API to read file:

FileUtils::getStringFromFile
FileUtils::getDataFromFile

#3

problem is getWritablePath’s return string is broken.
if username is ユーザー (=korean), getWritablePath’s return is ‘Invalid character in string’
because of username is not english.


#4

Why do you think it’s invalid?
It should be in UTF-8.


#5

getWritablePath’s return value is
C:\Users\1강의실-28번\AppData\Local\Connie
but “1강의실-28번”(korean) is broken data, so return is invalied value(value is ???) like this screenshot.
and my code is saved by signed utf-8(code 65001).
and i using #pragma execution_character_set(“UTF-8”) too.


#6

It should be valid.
You can’t see it just by chars in buffer because UTF-8 format is more complex.
One non-english character in UTF-8 can be 2 or 3 bytes in size.
To see real string you need to convert it to Unicode.