SFML community forums

Help => Window => Topic started by: codinglexernewbie on September 24, 2022, 07:46:49 am

Title: How to get unicode to be typed through sf::TextEntered
Post by: codinglexernewbie on September 24, 2022, 07:46:49 am
I want to be able to get Unicode letters e.g: ∏ by typing alt + 8719 like possible in Wordpad, but it doesn't seem to work using the default instead it turns into ☼(15), why does it reset after 256?, and is there a way to do what I want in the standard lib?
Title: Re: How to get unicode to be typed through sf::TextEntered
Post by: fallahn on September 24, 2022, 10:47:06 am
Unicode is complicated - see this post: https://stackoverflow.com/a/50407375/6740859

Broadly speaking std::string is mostly compatible with utf-8 but you may need to convert to/from codepoints (https://github.com/fallahn/crogine/blob/master/crogine/include/crogine/util/String.hpp#L161) when used with sf::String. In my experience I've found it best to try and stick to a unicode aware string class (like sf::String which is, admittedly, not the standard library but supports full 32 bit characters) and only convert when necessary, such as reading or writing a text file.