fix: charset lookup (#39187)

This commit is contained in:
wxiaoguang
2026-08-31 19:48:52 +08:00
committed by GitHub
parent 7c36ae7668
commit be3a6d1647
6 changed files with 64 additions and 42 deletions

View File

@@ -42,7 +42,6 @@ import (
"github.com/alecthomas/chroma/v2"
"github.com/sergi/go-diff/diffmatchpatch"
stdcharset "golang.org/x/net/html/charset"
"golang.org/x/text/encoding"
"golang.org/x/text/transform"
)
@@ -947,7 +946,7 @@ parsingLoop:
}
charsetLabel, _ := charset.DetectEncoding(buffer.Bytes())
if charsetLabel != "UTF-8" {
charsetEncoding, _ := stdcharset.Lookup(charsetLabel)
charsetEncoding, _ := charset.Lookup(charsetLabel)
if charsetEncoding != nil {
diffLineTypeDecoders[lineType] = charsetEncoding.NewDecoder()
}