|
@@ -62,6 +62,10 @@ func DetectEncoding(content []byte) (string, error) {
|
|
|
}
|
|
|
|
|
|
result, err := chardet.NewTextDetector().DetectBest(content)
|
|
|
+ if result == nil || err != nil {
|
|
|
+ return "UTF-8", err
|
|
|
+ }
|
|
|
+
|
|
|
if result.Charset != "UTF-8" && len(setting.Repository.AnsiCharset) > 0 {
|
|
|
log.Trace("Using default AnsiCharset: %s", setting.Repository.AnsiCharset)
|
|
|
return setting.Repository.AnsiCharset, err
|