Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In C#, how can I detect if a character is a non-ASCII character?

I would like to check, in C#, if a char contains a non-ASCII character. What is the best way to check for special characters such as or Ω?

like image 689
Alexandru Avatar asked Sep 03 '13 15:09

Alexandru


People also ask

What does |= mean in C?

The ' |= ' symbol is the bitwise OR assignment operator.

What is '~' in C programming?

In mathematics, the tilde often represents approximation, especially when used in duplicate, and is sometimes called the "equivalency sign." In regular expressions, the tilde is used as an operator in pattern matching, and in C programming, it is used as a bitwise operator representing a unary negation (i.e., "bitwise ...


1 Answers

ASCII ranges from 0 - 127, so just check for that range:

char c = 'a';//or whatever char you have bool isAscii = c < 128; 
like image 155
musefan Avatar answered Sep 21 '22 17:09

musefan