I want to change all filenames containing non Latin characters to a random unique Latin string. But how can I detect the existence of non Latin character in the original filenames?
The non-latin characters might be chinese, japanese, korean, arabic, umlaut, etc characters.
You could use regex:
if(Regex.IsMatch(input, "[^a-zA-Z]"))
{
// non-latin found
}
It will work for every letter different then a to z and A to Z.
If you'd like to allow digits too, use following: [^a-zA-Z0-9].
Non-regex solution
You could use LINQ as well, because string implements IEnumerable<char>:
if(input.ToLower().Any(c => c <= 'a' || c >= 'z'))
{
// non-latin found
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With