From 4993ab1a767bea5645a65b5639cc00bb107fdfd3 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 31 Dec 2015 22:13:47 -0500 Subject: #2185 fall back to use custom chardet lib --- modules/template/template.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'modules/template') diff --git a/modules/template/template.go b/modules/template/template.go index 6c070b7009..6099fcc987 100644 --- a/modules/template/template.go +++ b/modules/template/template.go @@ -130,8 +130,10 @@ func Sha1(str string) string { } func ToUtf8WithErr(content []byte) (error, string) { - charsetLabel := base.DetectEncoding(content) - if charsetLabel == "utf-8" { + charsetLabel, err := base.DetectEncoding(content) + if err != nil { + return err, "" + } else if charsetLabel == "UTF-8" { return nil, string(content) } -- cgit v1.2.3