Skip to content

Commit

Permalink
Use build in methods to check if a character is printable.
Browse files Browse the repository at this point in the history
  • Loading branch information
KN4CK3R committed May 2, 2019
1 parent 7c917fb commit b77f29e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ReClass.NET/Extensions/StringExtensions.cs
Expand Up @@ -13,7 +13,7 @@ public static class StringExtension
[DebuggerStepThrough]
public static bool IsPrintable(this char c)
{
return ' ' <= c && c <= '~';
return !char.IsControl(c) || char.IsWhiteSpace(c);
}

[DebuggerStepThrough]
Expand Down Expand Up @@ -75,6 +75,11 @@ public static float CalculatePrintableDataThreshold(this IEnumerable<char> sourc
}
}

if (countAll == 0)
{
return 0.0f;
}

return countValid / (float)countAll;
}

Expand Down

0 comments on commit b77f29e

Please sign in to comment.