mirror of
https://gitee.com/gitea/gitea.git
synced 2024-12-02 19:58:23 +08:00
Allow explicit charset/codepage setting for ANSI source files to alleviate issue #1088
This commit is contained in:
parent
31f6069dbe
commit
53bcf373c1
@ -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
|
||||
}
|
||||
|
||||
|
@ -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…
Reference in New Issue
Block a user