🐛 fix gbk garbled

This commit is contained in:
微凉
2021-11-15 19:20:39 +08:00
parent 82272fcbf5
commit da74e29b26
2 changed files with 48 additions and 1 deletions

View File

@ -99,9 +99,18 @@ func init() {
func Text(c *gin.Context, link string) {
res, err := client.R().Get(link)
text := res.String()
if utils.IsGBK(res.Body()) {
body, err := utils.GbkToUtf8(res.Body())
if err != nil {
ErrorResp(c,err,500)
return
}
text = string(body)
}
if err != nil {
ErrorResp(c,err,500)
return
}
c.String(200,res.String())
c.String(200,text)
}