Created
February 11, 2013 15:13
-
-
Save hoangtranwork/4755010 to your computer and use it in GitHub Desktop.
how about a public gist with gister
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment