1
System / Save/Load a vector<sf::String> without data lost
« on: June 12, 2016, 01:15:41 pm »
What is the simplest method to save or load a couple of sf::Strings without data lost?
This seems not to work correctly the output looks like the wrong encoding. example.txt is filled with Unicode characters and the output of a loaded sf::String looks like this: [][][][][][][]
std::ifstream file("example.txt");
string standardLine;
if(!file) return false;
while(std::getline(file, standardLine))
{
std::basic_string<sf::Uint32> utf32;
sf::Utf8::toUtf32(standardLine.begin(), standardLine.end(), std::back_inserter(utf32));
strings.push_back(utf32);
}
string standardLine;
if(!file) return false;
while(std::getline(file, standardLine))
{
std::basic_string<sf::Uint32> utf32;
sf::Utf8::toUtf32(standardLine.begin(), standardLine.end(), std::back_inserter(utf32));
strings.push_back(utf32);
}
This seems not to work correctly the output looks like the wrong encoding. example.txt is filled with Unicode characters and the output of a loaded sf::String looks like this: [][][][][][][]