Skip to content

Commit

Permalink
chore: support all GB* charsets
Browse files Browse the repository at this point in the history
  • Loading branch information
soulteary committed Dec 19, 2022
1 parent 490bc0e commit fba16e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 6 additions & 3 deletions internal/define/charset.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package define

const (
CHARSET_GBK = "gbk"
CHARSET_GB2312 = "gb2312"
CHARSET_UTF8 = "utf-8"
CHARSET_GBK = "gbk"
CHARSET_GB2312 = "gb2312"
CHARSET_GB18030 = "gb18030"
CHARSET_BIG5 = "big5"

CHARSET_UTF8 = "utf-8"
)
4 changes: 1 addition & 3 deletions internal/fn/charset.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ func DecodeHTMLBody(body io.Reader, charset string) (io.Reader, error) {
if charset == "" {
charset = DetectContentEncoding(body)
} else {
// use UTF-8 as fallback
// TODO maybe support more preset types
if !(charset == define.CHARSET_UTF8 || charset == define.CHARSET_GB2312 || charset == define.CHARSET_GBK) {
if !(charset == define.CHARSET_UTF8 || charset == define.CHARSET_GB2312 || charset == define.CHARSET_GBK || charset == define.CHARSET_GB18030) {
charset = define.DEFAULT_DOCUMENT_CHARSET
}
}
Expand Down

0 comments on commit fba16e8

Please sign in to comment.