So my code looks like this:
//This function is triggered in the main function
void game::events::mainEvents()
{
sf::Event Event;
while (game::Window->pollEvent(Event))
{
switch (Event.type)
{
case sf::Event::Closed:
game::events::Close(Event);
case sf::Event::Resized:
game::events::Resize(Event);
case sf::Event::MouseMoved:
game::events::MouseMove(Event);
case sf::Event::MouseButtonReleased:
game::events::MouseReleased(Event);
case sf::Event::TextEntered:
game::events::TextEntered(Event);
}
}
}
//This is the TextEntered-Event Function:
void game::events::TextEntered(sf::Event& Event)
{
for(unsigned int i = 0; i < game::gui::GUIManagerVector.size(); i++)
{
game::gui::GUIManagerVector[i]->CheckPossibleTextEntered(Event, *game::Window);
}
}
void game::gui::GUIManager::CheckPossibleTextEntered(sf::Event& Event, sf::RenderWindow& Window)
{
for(size_t i = 0; i < this->InputBoxes.size(); i++)
{
if (InputBoxes[i]->GetState())
{
char TempChar = static_cast<char>(Event.text.unicode);
std::string TempString(1, TempChar);
std::cout << TempString;
std::ofstream Write("weirdtext.txt", std::ios::app);
Write<< TempString;
Write.close();
InputBoxes[i]->AddText(TempString);
}
}
}
That is wrong:
char TempChar = static_cast<char>(Event.text.unicode);
std::string TempString(1, TempChar);
You should collect the UTF-32 characters you get in a sf::string. Then use sf::Text to draw it or do correct conversion to other encodings.