Files
bensema-gotdx/proto/util.go
2024-10-03 02:11:09 +08:00

21 lines
400 B
Go

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}), "")
}