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

Author Topic: [Linux] using sf::String makes the accents disapear  (Read 7431 times)

0 Members and 1 Guest are viewing this topic.

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: [Linux] using sf::String makes the accents disapear
« Reply #15 on: August 24, 2013, 10:18:58 pm »
The latest revision adds a sf::String::fromUtf8 function.
sfml 2.1? cool, I should update then

Quote
By the way, assuming an UTF-8 encoding on Linux is not 100% safe; although it is the default, I guess it can be changed.

I made the .txt and selected UTF-8 as the encoding, so I know it's utf-8

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6278
  • Thor Developer
    • View Profile
    • Bromeon
Re: [Linux] using sf::String makes the accents disapear
« Reply #16 on: August 24, 2013, 10:21:33 pm »
The latest revision adds a sf::String::fromUtf8 function.
sfml 2.1? cool, I should update then
No, the latest GitHub revision ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

FRex

  • Hero Member
  • *****
  • Posts: 1841
  • Not doing gamedev/using SFML lately
    • View Profile
    • Email
Re: [Linux] using sf::String makes the accents disapear
« Reply #17 on: August 24, 2013, 10:50:38 pm »
Quote
Quote

    By the way, assuming an UTF-8 encoding on Linux is not 100% safe; although it is the default, I guess it can be changed.


I made the .txt and selected UTF-8 as the encoding, so I know it's utf-8
I think Laurent meant that stdout, stderr and stdin might not speak UTF-8 at the moment. In Linux they do by default but in Windows they actually don't and the chars with top bit set are locale dependent.
Also, why use wchar_t and std::wstring, where did that idea come from? :P
I'm not using SFML nor doing any gamedev lately.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: [Linux] using sf::String makes the accents disapear
« Reply #18 on: August 24, 2013, 10:55:16 pm »
He said in the first post he's porting a Windows game to Linux, so that's probably why he has wstrings.

FRex

  • Hero Member
  • *****
  • Posts: 1841
  • Not doing gamedev/using SFML lately
    • View Profile
    • Email
Re: [Linux] using sf::String makes the accents disapear
« Reply #19 on: August 24, 2013, 10:59:45 pm »
But that's a terrible idea in the first place. :P
And he has UTF-8 file so there already is 1:1 mapping between std::string and file on disk, just load it and be done, no conversions in-between.
I'm not using SFML nor doing any gamedev lately.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: [Linux] using sf::String makes the accents disapear
« Reply #20 on: August 24, 2013, 11:40:19 pm »
I'm pretty sure wstrings are semi-mandatory on Windows if you want to avoid massive headaches (if only because the standard C++98 library has terrible Unicode support), and his original question was about a bug(?) in sf::String anyway so this isn't even relevant anymore.

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: [Linux] using sf::String makes the accents disapear
« Reply #21 on: August 25, 2013, 02:56:56 am »
if (want_to_read_story){

As I said before, I'm a beginner at programming. This was my first (relatively) big project, and I wanted to use accents. I did some research and stumbled upon wstrings, which (in windows) were the thing I wanted. Then when I tried to port it to linux, where wstrings didn't behaved the way I thought they would. There's when I stumbled upon (googling) loads of "use std::wstring for windows, and std::string for linux". Those answers, however, didn't take into consideration SFML, and were for console std::cout.

I know some things may seem obvious to you, but a year ago, I couldn't even print something on screen. I am learning c++ at my own pace, while at the same time doing Computer Science (let me tell you, intel asm is not a bed of roses). My next move is: make a good video, compile it to run on ubuntu 32 and 64 bits, licence it (I'm thinking MIT licence) and upload it to Ubuntu Software Center. If you see my code you will probably see things that can be better (using quadtrees to optimize for example), but I am proud of what I made.

}

Story aside, there wasn't a bug. You can see FRex's code or check the github revision for a solution.