Browse Source

Merge pull request #1399 from wqweto/develop

Allow explicit charset/codepage setting for ANSI source files to alle…
tags/v1.2.0-rc1
无闻 10 years ago
parent
commit
b3eec279ff
2 changed files with 5 additions and 0 deletions
  1. +3
    -0
      modules/base/template.go
  2. +2
    -0
      modules/setting/setting.go

+ 3
- 0
modules/base/template.go View File

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



+ 2
- 0
modules/setting/setting.go View File

@@ -84,6 +84,7 @@ var (
// Repository settings.
RepoRootPath string
ScriptType string
AnsiCharset string

// UI settings.
IssuePagingNum int
@@ -312,6 +313,7 @@ func NewConfigContext() {
RepoRootPath = path.Clean(RepoRootPath)
}
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
AnsiCharset = sec.Key("ANSI_CHARSET").MustString("ISO-8859-1")

// UI settings.
IssuePagingNum = Cfg.Section("ui").Key("ISSUE_PAGING_NUM").MustInt(10)


Loading…
Cancel
Save