Hi... I'm trying to display spanish strings with accents under Linux.. with no luck
My GCC version is 4.7.2
Recent SFML 2.0 (compiled by me)
Linux Fedora 18 x64
Codelite IDE
Here is my minimal example:
#include <iostream>
#include <string>
#include <SFML/Graphics.hpp>
using std::cout;
using std::endl;
int main() {
// Create the main window
sf::RenderWindow window (sf::VideoMode (800, 600), "String Test");
// Load font
sf::Font myFont;
if (!myFont.loadFromFile("./fuente.ttf")) {
cout << "error loading font" << endl;
return -1;
}
// Wide string
const wchar_t *myStringW = L"wide string: áéíóú";
cout << myStringW << endl;
sf::Text myTextW (myStringW, myFont, 50);
myTextW.setPosition(20, 100);
// ANSI string
const char *myANSIstring = "ANSI string: áéíóú";
cout << myANSIstring << endl;
sf::Text myANSItext (myANSIstring, myFont, 50);
myANSItext.setPosition(20, 150);
// Start the game loop
while (window.isOpen()) {
// Process events
sf::Event event;
while (window.pollEvent(event)) {
// Close window : exit
if (event.type == sf::Event::Closed)
window.close();
}
// Clear screen
window.clear();
// Draw
window.draw(myTextW);
window.draw(myANSItext);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}
The wide string displays correctly using
sf::Text. The ANSI string does
not display accents.
Should I always use wide strings under Linux?
[attachment deleted by admin]