#2185 use Go sub-repo to detect encoding

This commit is contained in:
Unknwon 2015-12-13 19:56:33 -05:00
parent 79dcd7ee6e
commit 95f9c85bcc
7 changed files with 11 additions and 21 deletions

View file

@ -244,8 +244,8 @@ func ParsePatch(maxlines int, reader io.Reader) (*Diff, error) {
buf.WriteString("\n")
}
}
charsetLabel, err := base.DetectEncoding(buf.Bytes())
if charsetLabel != "UTF-8" && err == nil {
charsetLabel := base.DetectEncoding(buf.Bytes())
if charsetLabel != "UTF-8" {
encoding, _ := charset.Lookup(charsetLabel)
if encoding != nil {
d := encoding.NewDecoder()