hoangtranwork
2/11/2013 - 3:13 PM

how about a public gist with gister

how about a public gist with gister

        private static Encoding DetectEncoding(byte[] inputBytes, int offset, int len)
        {
            var detector = new CharsetDetector();
            detector.Feed(inputBytes, offset, len);
            detector.DataEnd();

            string result = detector.Charset;
            Encoding encoding = Encoding.UTF8;
            if (!string.IsNullOrEmpty(result) && detector.Confidence <= (double) DetectionConfidence.SureAnswer)
            {
                encoding = Encoding.GetEncoding(result);
            }
            return encoding;
        }