Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

(Previously asked at

I've just started using SFML and one of the first problems I've come across is some weird characters on the the titlebar whenever I try to use accents or any other extended char.

For instance, I've got:

sf::RenderWindow Ventana(sf::VideoMode(800, 600, 32), "Año nuevóóó");

And the titlebar renders like AÂ+o nuevoA³A³A³

This ONLY HAPPENS if my source code file is enconded in UTF-8. If I change the file encoding to ISO-8859-1, it shows properly. Obviously all of my files use UTF-8, as its the system-wide encoding. I'm using GCC under Ubuntu GNU/Linux.

I've tried using the different utilities in sf::Unicode to adapt the text, but none of them seems to work.

share|improve this question
This isn't really game development related, though I see you came here after receiving no response from SO after two days... Have you tried the SFML forums? – Ricket Feb 9 '11 at 22:30
One of the problems in debugging problems like this is that the issue can lie anywhere from passing the wrong -fexec-charset to GCC to your window manager implementing Unicode conversion incorrectly. The best approach is usually to break out a debugger and step through as much as you need to to see what failed. – user744 Feb 9 '11 at 23:07

1 Answer 1

IF your source code file is in UTF-8 then those non-ASCII characters can be represented by more than one byte. eg. 'ó' is represented by 'A³' (or perhaps more accurately, 'ó' is represented by values that render as 'A³'). I think you should be very careful when using UTF-8 source files since C++ string literals imply 1 byte per character but UTF-8 characters break that assumption. I'd recommend switching to a fixed-width representation like ISO-8859-1 for your source files.

The SFML RenderWindow constructor takes a "const std::string &Title" - this has no encoding specified, but it gets passed through to a WindowImpl class which decides how to pass the string to the OS. It looks like Win32 makes an attempt at handling Unicode, but I don't have the Unix/X code to hand. I suggest looking through that and seeing if it does something similar. Either way, the std::string carries no encoding information at all so it's risky to use anything but ASCII, unless SFML explicitly states what kind of text encoding to supply.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.