fix: File content support GBK encoding (#9198)

This commit is contained in:
2025-06-20 14:43:13 +08:00 committed by GitHub
parent 0c64c8ff52
commit bb99853000
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -337,7 +337,7 @@ func (f *FileService) GetContent(op request.FileContentReq) (response.FileInfo,
}
if !utf8.Valid(content) {
_, decodeName, _ := charset.DetermineEncoding(content, "")
if decodeName == "windows-1252" {
if decodeName == "windows-1252" || strings.ToLower(decodeName) == "gbk" {
reader := strings.NewReader(info.Content)
item := transform.NewReader(reader, simplifiedchinese.GBK.NewDecoder())
contents, err := io.ReadAll(item)