Home c++ C++ | SFML | Hieroglyphs instead of Cyrillic | Write text from...

C++ | SFML | Hieroglyphs instead of Cyrillic | Write text from a variable in Russian




I can not display the Russian text. Viewed all sorts of sites, found such a way:

text.setstring (L "SOME TEXT");
  Window.draw (Text);

and yes, it works , Russian text is displayed correctly.

But all the evil is that I take the text from XML using TinyXML2, i.e. I carry the text in variable , and I can no longer add prefix L for his work. I tried a way with wstring , I did not find a normal explanation, as it works and what to put, copied, did not work.


& lt; root & gt;
  & lt; info & gt;
    & lt; map_name & gt; XML file is actually more, just here I save place & lt; / map_name & gt;
  & lt; / info & gt;
& lt; / root & gt;


// map_document - an XMLDocument object to which the XML document is applied above
Xmlnode * root = Map_Document- & gt; firstchildelement ("root");
Xmlelement * Element = root- & gt; firstchildelement ("info");
Map :: map_name = element- & gt; firstchildelement ("map_name") - & gt; gettext (); // Code taken from the map designer
// When I write in XML English text, everything is displayed normally, all the code is higher, consider, just takes the text from XML & LT; Map_Name & GT;
//... Highlands Announcement of text and windows ... Map1 - MAP object
SF :: String Test_String = Map1.getMapname (); // Function, gives map_name above, from English, everything works correctly
Window.draw (Text);

Help what to use to withdraw Russian text (Cyrillic), ! From the variable! .

Answer 1, Authority 100%

Hooray, 7 bombing hours later (and because I have already been faced with this)

string map_name = test_map.getmapname ();
text.setstring (String :: FROMUTF8 (MAP_NAME.BEGIN (), MAP_NAME.End ()));

Solution – SF :: String :: FROMUTF8 (Youstring.begin (), Youstring.end ())

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions