Search code examples
c#stringunicodecharascii

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 Ω?


Solution

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

    char c = 'a';//or whatever char you have
    bool isAscii = c < 128;