Groups | Blog | Home
all groups > c# > june 2005 >

c# : How do I recognize space characters in keyboard input?



steve bull
6/20/2005 11:44:59 PM

I would like to recognize whitespace or nonascii characters in keyboard input. Is there an easy way to do this test? I
could do

e.KeyChar < '!' || e.KeyChar > '~'

but this seems to make the assumption that the user is inputting ascii characters - but maybe they are using some other
character set.

Can I use \s or is this for regular expression use only.


sorry it is such a basic question.

Thanks,

Steve
Rodger Constandse
6/21/2005 12:00:00 AM
Hi,

Have you tried the static Char.IsXXX set of functions (Char.IsWhitespace ,
Char.IsLetter, etc.) They take a char as input and handle Unicode as well.

They may provide the functionality you are looking for.

\s only works as part of regular expressions.

Best regards,

Rodger

Time Management Guide - Make better use of your time
<http://www.TimeThoughts.com/timemanagement.htm>


[quoted text, click to view]
steve bull
6/21/2005 3:40:02 AM

thanks, I knew it had to be something simple.

Steve


[quoted text, click to view]
AddThis Social Bookmark Button