Hello there!
I am trying to load an utf8-encoded text file into a std::vector<sf::String>. When I use
this litte, but great library everything works as supposed to. After doing
void load(std::vector<sf::String>& lines) {
// Open the test file (contains UTF-8 encoded text)
std::ifstream fileStream("unitext.txt");
std::string line;
while (std::getline(fileStream, line)) {
std::basic_string<sf::Uint32> utf32line;
// this line converts utf8 to utf32 with the help of the metioned library
utf8::utf8to32(line.begin(), line.end(), back_inserter(utf32line));
lines.push_back(utf32line);
}
}
the vector "lines" contains utf-32 encoded sf::Strings.
But since SFML supports utf conversions as well, I tried to do the same, only with SFML. Therefore I changed
utf8::utf8to32( ... );
to
sf::Utf8::ToUtf32( ... );
which, as I thought, should result in exactly the same behaviour. But it doesn't: When there is a non-ascii character, all trailing characters are dropped.
Am I doing something wrong :? ? Or is it a bug :shock: ?
Greetings, Simon.