From 8b7d644958cb6d430c816e051bacffb38f8657ac Mon Sep 17 00:00:00 2001 From: Lendemor Date: Sun, 22 Jan 2017 17:50:49 +0100 Subject: [PATCH] switched from string to wstring --- src/input.cpp | 9 +++++---- src/input.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index bf7f119..e114cd4 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -55,7 +55,9 @@ void Input::updateEvents(){ break; case sf::Event::TextEntered: c = (char) event.text.unicode; - m_buffer.push_back(c); + sf::Utf32::encodeAnsi(event.text.unicode,std::back_inserter(m_buffer)); +// std::cout << << std::endl; +// m_buffer.push_back('\u9190'); break; case sf::Event::KeyPressed: action = kb.getPressedAction(event.key.code); @@ -182,10 +184,9 @@ void Input::setMouseGrabbed(bool isGrabbed) m_last_mouse_position = sf::Vector2i(m_window->getSize())/2; } -std::string Input::getText() +std::wstring Input::getText() { - std::string t = m_buffer; - return t; + return m_buffer; } /* ------ */ diff --git a/src/input.h b/src/input.h index 1958ef6..37b5acc 100644 --- a/src/input.h +++ b/src/input.h @@ -38,7 +38,7 @@ private: bool m_mouseGrabbed; /* text-related variable */ - std::string m_buffer; + std::wstring m_buffer; public: /* Constructors */ Input(sf::Window *w); @@ -72,7 +72,7 @@ public: bool isMouseGrabbed() const { return m_mouseGrabbed; } /* text-related function */ - std::string getText(); + std::wstring getText(); void test(); };