Text files Unicode charset detector w/wo BOM.
$ dotnet add package UnicodeCharsetDetector.StandardText files Unicode charset w/wo BOM detector. Encodings supported:
UTF-7UTF-8UTF-16UTF-32Example application can be found here.
// Get file encoding.
var unicodeCharsetDetector = new UnicodeCharsetDetector.UnicodeCharsetDetector();
using var stream = File.OpenRead(fileName);
var charset = unicodeCharsetDetector.Check(stream);
var encoding = charset.ToEncoding();