feat:添加铅笔小说搜索插件 (#89)

* feat:添加铅笔小说搜索插件

* fix:小修改help

* fix:微调语句

* fix:替换编码库

* fix:不修改go.sum
This commit is contained in:
himawari
2021-12-19 16:05:29 +08:00
committed by GitHub
parent 5ff9069ff2
commit fd85ce0923
5 changed files with 222 additions and 1 deletions

29
utils/encode/encode.go Normal file
View File

@@ -0,0 +1,29 @@
package encode
import (
"bytes"
"io/ioutil"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
)
// GBK 转 UTF-8
func GbkToUtf8(s []byte) ([]byte, error) {
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewDecoder())
d, e := ioutil.ReadAll(reader)
if e != nil {
return nil, e
}
return d, nil
}
// UTF-8 转 GBK
func Utf8ToGbk(s []byte) ([]byte, error) {
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewEncoder())
d, e := ioutil.ReadAll(reader)
if e != nil {
return nil, e
}
return d, nil
}