Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor digit check logic to use CharUtils utility 🔧 #8951

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Refactor digit check logic to use CharUtils utility
Replaced occurrences of `char.IsDigit` with `CharUtils.IsDigit` for consistency and potential future enhancements. This change improves the readability and maintainability of the code by centralizing character utility functions.

Related to #1899

Signed-off-by: Ivandro Jao <Ivandrofly@gmail.com>
ivandrofly committed Oct 28, 2024
commit b9580435e2346679146b6f513fd8df9b02f9b3be
10 changes: 5 additions & 5 deletions src/libse/SubtitleFormats/SubRip.cs
Original file line number Diff line number Diff line change
@@ -291,7 +291,7 @@ private static string RemoveBadChars(string line)
private bool TryReadTimeCodesLine(string input, Paragraph paragraph, bool validate)
{
var s = input.TrimStart('-', ' ');
if (s.Length < 10 || !char.IsDigit(s[0]))
if (s.Length < 10 || !CharUtils.IsDigit(s[0]))
{
return false;
}
@@ -428,7 +428,7 @@ private static bool IsValidTimeCode(string line)

if (step == 0 || step == 2 || step == 4 || step == 9 || step == 11) // start numbers
{
if (ch == '-' || char.IsDigit(ch))
if (ch == '-' || CharUtils.IsDigit(ch))
{
step++;
}
@@ -439,7 +439,7 @@ private static bool IsValidTimeCode(string line)
}
else if (step == 1 || step == 3 || step == 10 || step == 12) // number
{
if (char.IsDigit(ch))
if (CharUtils.IsDigit(ch))
{
// ok
}
@@ -454,7 +454,7 @@ private static bool IsValidTimeCode(string line)
}
else if (step == 5 || step == 13) // seconds
{
if (char.IsDigit(ch))
if (CharUtils.IsDigit(ch))
{
// ok
}
@@ -469,7 +469,7 @@ private static bool IsValidTimeCode(string line)
}
else if (step == 6 || step == 14) // milliseconds
{
if (char.IsDigit(ch))
if (CharUtils.IsDigit(ch))
{
// ok
}