Last active
August 9, 2019 22:01
-
-
Save mosra/1ba7fd9f4eb6d9fe1a6308ff96fad500 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ -std=c++11 sdl-setwindowtitle.cpp -lSDL2 | |
#include <SDL2/SDL.h> | |
int main() { | |
SDL_Init(SDL_INIT_VIDEO); | |
SDL_Window* w = SDL_CreateWindow( | |
/* If you flip this, SDL_SetWindowTitle() below starts working */ | |
#if 1 | |
"Title without UTF-8", | |
#else | |
"Title — with an UTF-8 em-dash", | |
#endif | |
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, | |
800, 600, 0); | |
/* If you call this, the below stops working */ | |
//SDL_SetWindowTitle(w, "Another title without UTF-8"); | |
/* This works only if the previously set title had an em-dash as well */ | |
SDL_SetWindowTitle(w, "Another title — with an UTF-8 em-dash"); | |
SDL_Event event; | |
while(SDL_WaitEvent(&event)) | |
if(event.type == SDL_QUIT) break; | |
SDL_DestroyWindow(w); | |
SDL_Quit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment