I’m making application which should be able to take string input from user (via input fields etc.) Important feature is that text MUST be only in Latin letters. How can I detect non-latin letters so that I could notify users about such input details.
//char can be casted to int to acquire letter’s code
//returns true if letters are latin
bool CheckForNotLatin(string stringToCheck)
{
bool boolToReturn = false;
foreach (char c in stringToCheck)
{
int code = (int)c;
// for lower and upper cases respectively
if ((code > 96 && code < 123) || (code > 64 && code < 91))
boolToReturn = true;
// visit C# ASCII Table - Dot Net Perls for more codes
}
return boolToReturn;
}