Question by
Grosswood · Aug 26, 2015 at 12:55 PM ·
inputstringinputfieldtranslationlanguages
How to detect non-latin letters?
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.
Comment
Best Answer
Answer by Grosswood · Sep 09, 2015 at 06:30 AM
//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 http://www.dotnetperls.com/ascii-table for more codes
}
return boolToReturn;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612001510im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Input Field Problem 0 Answers
I cant Multiply integer from Input Field 1 Answer
Detecting if is currently entering text on any component. 0 Answers
Input field android problems 0 Answers
Localization Playerprefs remember language on startup 1 Answer