Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ internal static class ZipHelper

internal static Encoding GetEncoding(string text)
{
foreach (char c in text)
if (text.AsSpan().IndexOfAnyExceptInRange((char)32, (char)126) >= 0)
{
// The Zip Format uses code page 437 when the Unicode bit is not set. This format
// is the same as ASCII for characters 32-126 but differs otherwise. If we can fit
// the string into CP437 then we treat ASCII as acceptable.
if (c > 126 || c < 32)
{
return Encoding.UTF8;
}
return Encoding.UTF8;
}

return Encoding.ASCII;
}

Expand Down