SFML community forums
Help => System => Topic started by: dydya-stepa on March 05, 2012, 06:01:31 pm
-
I want to allow only text characters for a textbox. How can I filter out all the other characters from evt.Text.Unicode. I'm talking about commas, semicolons and so on.
-
Every character has a number: http://www.asciitable.com/
For only the letters you will need to do this:
if (((evt.Text.Unicode > 64) && (evt.Text.Unicode < 91)) // check for capital letters
|| ((evt.Text.Unicode > 96) && (evt.Text.Unicode < 123))) // and check for lowercase
{
// add the letters to the textbox
}
-
isn't that for english only? i want ALL languages as stated in the name of the topic
http://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF
3rd an 4th section contain also crappy characters.
-
Sorry, I didn't read the topic name.
You might want to check out functions like iswalpha.
-
good idea. does sfml support this ? can I use sfml's evt.Text.Unicode with c/c++ build in functions?
-
iswalpha expects a wide character, but it's not clear what encoding it works with.
If you need to classify Unicode characters, you should use a true Unicode library. You won't do anything good with only standard functions; they are not made for Unicode.
-
texus, when working with ASCII, I would rather use the meaningful char literals instead of magic numbers, e.g. 'A'.
-
You are absolutely right, that would be clearer.