mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-17 14:00:01 +02:00
Fix UTF-8 in upper-case, use ansi charset for all non UTF-8 encodings
This commit is contained in:
parent
4917d29c12
commit
2cc050e21e
3 changed files with 4 additions and 4 deletions
|
@ -55,7 +55,7 @@ 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" {
|
||||
if result.Charset != "UTF-8" && len(setting.AnsiCharset) > 0 {
|
||||
return setting.AnsiCharset, err
|
||||
}
|
||||
return result.Charset, err
|
||||
|
@ -67,7 +67,7 @@ func ToUtf8WithErr(content []byte) (error, string) {
|
|||
return err, ""
|
||||
}
|
||||
|
||||
if charsetLabel == "utf8" {
|
||||
if charsetLabel == "UTF-8" {
|
||||
return nil, string(content)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue