CharsetDetector / UTF-unknown

Character set detector build in C# - .NET 5+, .NET Core 2+, .NET standard 1+ & .NET 4+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove static methods from CharsetDetector, add an interface and create CharsetDetector.Instance

304NotModified opened this issue · comments

For mocking.

e.g.

interface ICharsetDetector
{
  DetectionResult DetectFromBytes(byte[] bytes);
  DetectionResult DetectFromBytes(byte[] bytes, int offset, int len); 
  DetectionResult DetectFromStream(Stream stream);
  DetectionResult DetectFromStream(Stream stream, long? maxBytesToRead);
}

public class CharsetDetector 
{
   public ICharsetDetector Instance => _instance;
}

and move to extensions for SRP:

public static class CharsetDetectorFileExtensions
{
public static DetectionResult DetectFromFile(this ICharsetDetector detector, string filePath) {...}
public static DetectionResult DetectionResult DetectFromFile(this ICharsetDetector detector, FileInfo file) {...}