Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why is sf::String removing unknow ascii characters ?  (Read 2212 times)

0 Members and 1 Guest are viewing this topic.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Why is sf::String removing unknow ascii characters ?
« on: December 31, 2015, 09:43:52 am »
Hi, I've coded a custom filedialog, the problem is when my std::string contains the character 'é' by example, the character is removed by sf::String and it fails to open my file.
std::string Label::getText() {
       return text.getString().toAnsiString();
}
 
std::string currentDir = lTop.getText();
std::cout<<fileName<<std::endl;
currentDir += "/"+fileName;
std::cout<<currentDir<<std::endl;
std::string currentDir = lTop.getText();
std::cout<<fileName<<std::endl;
currentDir += "/"+fileName;
std::cout<<currentDir<<std::endl;
lTop.setText(currentDir);
if (DIR* current = opendir(currentDir.c_str())) {
 
By exemple sf::String replace développement by dveloppement and I get a no such file or directory error. (Wtf  :o)
So I've just changed the type of sf::String to std::string into the sf::Text class and now it works.

There isn't any unicode version of the opendir function, so I really suggest you to don't remove unknow characters for ansi strings.
« Last Edit: December 31, 2015, 10:26:43 am by Laurent »

TheGoldenFyre

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Why is sf::String removing unknow ascii characters ?
« Reply #1 on: December 31, 2015, 01:55:17 pm »
Isn't there the L modifier? I'm not sure...