Skip to content

Commit

Permalink
.net 9 use built-in functions to check ascii chars
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-Juhasz committed Dec 27, 2024
1 parent 5bab356 commit c54a678
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Science.Cryptography.Ciphers/Extensions/CharExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public static partial class CharExtensions
public static char ToSameCaseAs(this char newChar, char reference) => Char.IsLower(reference) ? newChar.ToLowerInvariant() : newChar;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsUpperAsciiLetter(this char newChar) => newChar >= 'A' && newChar <= 'Z';
public static bool IsUpperAsciiLetter(this char newChar) => Char.IsAsciiLetterUpper(newChar);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsLowerAsciiLetter(this char newChar) => newChar >= 'a' && newChar <= 'z';
public static bool IsLowerAsciiLetter(this char newChar) => Char.IsAsciiLetterLower(newChar);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsAsciiLetter(this char newChar) => newChar.IsUpperAsciiLetter() || newChar.IsLowerAsciiLetter();
public static bool IsAsciiLetter(this char newChar) => Char.IsAsciiLetter(newChar);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsDigit(this char newChar) => newChar >= '0' && newChar <= '9';
public static bool IsAsciiDigit(this char newChar) => Char.IsAsciiDigit(newChar);
}

0 comments on commit c54a678

Please sign in to comment.