Merge pull request #1399 from wqweto/develop

Allow explicit charset/codepage setting for ANSI source files to alle…
release/v1.15
无闻 2015-07-28 14:23:16 +08:00
commit 7d8121b077
2 changed files with 5 additions and 0 deletions

View File

@ -55,6 +55,9 @@ func ShortSha(sha1 string) string {
func DetectEncoding(content []byte) (string, error) { func DetectEncoding(content []byte) (string, error) {
detector := chardet.NewTextDetector() detector := chardet.NewTextDetector()
result, err := detector.DetectBest(content) result, err := detector.DetectBest(content)
if result.Charset == "ISO-8859-1" {
return setting.AnsiCharset, err
}
return result.Charset, err return result.Charset, err
} }

View File

@ -84,6 +84,7 @@ var (
// Repository settings. // Repository settings.
RepoRootPath string RepoRootPath string
ScriptType string ScriptType string
AnsiCharset string
// UI settings. // UI settings.
IssuePagingNum int IssuePagingNum int
@ -312,6 +313,7 @@ func NewConfigContext() {
RepoRootPath = path.Clean(RepoRootPath) RepoRootPath = path.Clean(RepoRootPath)
} }
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash") ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
AnsiCharset = sec.Key("ANSI_CHARSET").MustString("ISO-8859-1")
// UI settings. // UI settings.
IssuePagingNum = Cfg.Section("ui").Key("ISSUE_PAGING_NUM").MustInt(10) IssuePagingNum = Cfg.Section("ui").Key("ISSUE_PAGING_NUM").MustInt(10)