[StringExtensions] - Minor optimization for ContainsLetter().

This commit is contained in:
Ivandro Ismael 2016-08-31 22:10:24 +01:00
parent 294b3f646e
commit ea42ec4184
No known key found for this signature in database
GPG Key ID: A8832757DEFB7EDC

View File

@ -153,13 +153,14 @@ namespace Nikse.SubtitleEdit.Core
public static bool ContainsLetter(this string s) public static bool ContainsLetter(this string s)
{ {
if (string.IsNullOrWhiteSpace(s)) if (s != null)
return false;
foreach (var c in s)
{ {
if (char.IsLetter(c)) foreach (var index in StringInfo.ParseCombiningCharacters(s))
return true; {
var uc = CharUnicodeInfo.GetUnicodeCategory(s, index);
if (uc == UnicodeCategory.LowercaseLetter || uc == UnicodeCategory.UppercaseLetter || uc == UnicodeCategory.TitlecaseLetter || uc == UnicodeCategory.ModifierLetter || uc == UnicodeCategory.OtherLetter)
return true;
}
} }
return false; return false;
} }