新增options来配置

This commit is contained in:
bense
2024-10-03 02:11:09 +08:00
parent bfff0f62be
commit 432b27f52b
11 changed files with 119 additions and 99 deletions

20
proto/util.go Normal file
View File

@@ -0,0 +1,20 @@
package proto
import (
"bytes"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
"io/ioutil"
"strings"
)
func Utf8ToGbk(text []byte) string {
r := bytes.NewReader(text)
decoder := transform.NewReader(r, simplifiedchinese.GBK.NewDecoder()) //GB18030
content, _ := ioutil.ReadAll(decoder)
return strings.ReplaceAll(string(content), string([]byte{0x00}), "")
}