SFML title bar with weird characters when using UTF-8

José Tomás Tocino
  • SFML title bar with weird characters when using UTF-8 José Tomás Tocino

    (Previously asked at https://stackoverflow.com/questions/4922478/sfml-title-bar-with-weird-characters-when-using-utf-8)

    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.

  • 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.

c++ sfml
Related questions and answers
  • Components in GameSubsystems (when GameObject is created and composed). There are 4 approaches: 1: Chain of responsibility pattern. Every Component is offered to every GameSubsystem. GameSubsystem makes... coupling. A. We can add new GameSubsystem. For example, let's add GameSubsystemTitles that registers all ComponentTitle and guarantees that every title is unique and provides interface to quering objects by title. Of course, ComponentTitle should not be rewrited or inherited in this case. B. We can reorganize existing GameSubsystems. For example, GameSubsystemAudio, GameSubsystemRender

  • using the boost library extensively and have been using SFML for graphics and FMOD for audio. I have a fair bit of code written, but am considering scrapping it and starting over. Here's the major... sort of designs other people used to overcome them, or would use. For a little background, I started working on it in my free time last summer. I was initially making the game in C#, but about 3 months... parties, and the party class has a list of BaseCharacters introducing another cyclical dependency. 2 - Events In C# I made extensive use of delegates to hook into events on characters, battle

  • Sorry for the ackward title, but i don't know what to call it exactly. I'm looking for code or libraries that allow easy creation of commonly used user input devices, and code/libs that make gaming controls easy to set up (i'm using SFML and Box2D at the moment) I don't want to re-invent things like buttons, arrows being placed wherever the mouse is located, and more game specific items... or resources out there that i can use to avoid spending much of my time coding these now standard input devices/tecniques?

  • I am quite new to OpenGL, I have managed after long trial and error to integrate Nehe's Cel-Shading rendering with my Model loaders, and have them drawn using the Toon shade and outline... ) if (In) // Check To See If The File Opened ( NEW ) { for (i = 0; i < 32; i++) // Loop Though The 32 Greyscale Values ( NEW... (TOON SHADE) glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); // Use The Good Calculations ( NEW ) glEnable (GL_LINE_SMOOTH); // Cel-Shading Code // glEnable (GL_TEXTURE_1D

  • this on what I had done there, but modifying it to fit with Ogre. It is working but not correctly and I would like some help to understand what it is I am doing wrong. I have a state system and when... code shows the changes I made to get accurate physics. void GameState::createScene() { m_pSceneMgr->createLight("Light")->setPosition(75,75,75); // Physics // As a test we want a floor plane...(TPosition); // Give it to the motion state btDefaultMotionState *MotionState = new btDefaultMotionState(Transform); // I got the size of the bounding box above but wasn't using it to set

  • code in them... Right now for testing purposes, I just have the main loop call Level1 level1; and use the functions, but when I run the game I get a segmentation fault. This is the first time I've...I'm trying to write my level classes by having a base class that each level class inherits from...The base class uses pure virtual functions. My base class is only going to be used as a vector that'll have the inherited level classes pushed onto it...This is what my code looks like at the moment, I've tried various things and get the same result (segmentation fault). //level.h class Level

  • Possible Duplicate: When to roll your own game engine? I've been interested in writting games for a while, and now that I have acquired a bit of experience in programming, I feel like I could step up to making a little more complicated things. I've had some fun with SFML but since now I only had the basic classes I needed for my game objects, and a big run() method of my Game object... no professional, and I don't have a clear view of "how-to" yet. I am using SFML with C++.

  • I'm rendering to a depth map in order to use it as a shader resource view, but when I sample the depth map in my shader, the red component has a value of 1 while all other channels have a value of 0. The Texture2D I use to create the DepthStencilView is bound with the D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE flags, the DepthStencilView has the DXGI_FORMAT_D32_FLOAT format...; #if defined(DEBUG) || defined(_DEBUG) deviceFlags |= D3D11_CREATE_DEVICE_DEBUG | D3D11_RLDO_DETAIL; #endif This is how I create my depth map. I've omitted error checking for the sake of brevity

  • to implement the game engine. So I thought my game engine should control this things: - Moving the objects in the scene - Checking the collisions - Adjusting movements based on collisions - Passing the polygons to the rendering engine I designed my objects like this: class GlObject{ private: idEnum ObjId; //other identifiers public: void move_obj(); //the movements are the same... different objects in my game: plane, obstacle, player, bullet and I designed them like this: class Player : public GlObject{ private: std::string name; public: Player(); Bullet fire() const

Data information