From 93f03707a789a4d538c945c9838fa4ec4d3ef15c Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 25 Dec 2015 05:45:07 -0500 Subject: #2283 set text/plain for non-binary files in raw mode --- modules/base/tool.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/base/tool.go b/modules/base/tool.go index 9dcbb881d5..75f475fa4f 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -53,7 +53,11 @@ func ShortSha(sha1 string) string { } func DetectEncoding(content []byte) string { - _, name, certain := charset.DetermineEncoding(content, setting.Repository.AnsiCharset) + _, name, certain := charset.DetermineEncoding(content, "") + if name != "utf-8" && len(setting.Repository.AnsiCharset) > 0 { + log.Debug("Using default AnsiCharset: %s", setting.Repository.AnsiCharset) + return setting.Repository.AnsiCharset + } log.Debug("Detected encoding: %s (%v)", name, certain) return name } -- cgit v1.2.3