Merge pull request #8349 from ivandrofly/start-with-upper

Refactor method to check string starts with lowercase letter
This commit is contained in:
Nikolaj Olsson 2024-06-05 07:18:14 +02:00 committed by GitHub
commit 7b75b154ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -91,22 +91,15 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
private static bool CanCapitalize(string input, IFixCallbacks callbacks) private static bool CanCapitalize(string input, IFixCallbacks callbacks)
{ {
return !IsAppleNaming(input) && BeginsWithLetter(input); return !IsAppleNaming(input) && IsFirstLetterConvertibleToUppercase(input);
} }
/// <summary> /// <summary>
/// Returns true if first character is convertible to uppercase otherwise false /// Returns true if first character is convertible to uppercase otherwise false
/// </summary> /// </summary>
private static bool BeginsWithLetter(string input) private static bool IsFirstLetterConvertibleToUppercase(string input)
{ {
if (input.Length == 0) return input.Length > 0 && char.IsLower(input[0]);
{
return false;
}
var ch = input[0];
return char.IsLetter(ch) && char.IsLower(ch);
} }
/// <summary> /// <summary>