Merge pull request #1935 from ivandrofly/se

[StringExtensions] - Minor optimization for ContainsLetter().
This commit is contained in:
Nikolaj Olsson 2016-09-04 21:37:50 +02:00 committed by GitHub
commit e5691b7a15

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;
} }