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

Author Topic: From UTF-8 encoded xml file to a sf::String  (Read 3713 times)

0 Members and 1 Guest are viewing this topic.

Sumzary

  • Guest
From UTF-8 encoded xml file to a sf::String
« on: September 27, 2013, 04:04:11 pm »
I'm working on a game project and want it to be translatable to most, if not all languages, similar to minecraft.

I've got a "Something.xml" with some japanese letters in an attribute:




Currently I am using this code to get a line from the file to an sf::String using TiCPP:

sf::String GetText(const char *_category, const char *_line) {
        ticpp::Element *category = langFile.FirstChildElement(_category);
        std::string lineStr;
        category->GetAttribute(_line, &lineStr);
        return sf::String::fromUtf8(lineStr.begin(), lineStr.end());
}


The result is that the ÕÄÖÜ get shown, but the japanese characters don't:




What should the code be?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: From UTF-8 encoded xml file to a sf::String
« Reply #1 on: September 27, 2013, 04:14:44 pm »
Are you sure that the font that you use to display text has Japanese characters?
Laurent Gomila - SFML developer

Sumzary

  • Guest
Re: From UTF-8 encoded xml file to a sf::String
« Reply #2 on: September 27, 2013, 04:38:57 pm »
I am using the same font I used in that Notepad++ screenshot, Unifont, so yes.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: From UTF-8 encoded xml file to a sf::String
« Reply #3 on: September 27, 2013, 04:59:05 pm »
This is one of the few times Laurent can lay back and laugh because it is SFGUI's fault that your glyphs aren't being loaded properly :D. Some time back, we decided to hardcode the set of glyphs that were loaded out of a font because we are using quite a big unicode one by default.

I don't know what codepoint range your glyphs lie in, but you can experiment by changing the necessary lines in Renderer.cpp.

This is the spot: http://redmine.boxbox.org/projects/sfgui/repository/revisions/master/entry/src/SFGUI/Renderer.cpp#L788
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Sumzary

  • Guest
Re: From UTF-8 encoded xml file to a sf::String
« Reply #4 on: September 27, 2013, 05:13:28 pm »
Thanks a bunch dude,  I was in a bit of a pinch there!  ;D

 

anything