mirror of
https://github.com/bensema/gotdx.git
synced 2025-11-21 10:55:34 +08:00
readme
This commit is contained in:
20
util/string.go
Normal file
20
util/string.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package util
|
||||
|
||||
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}), "")
|
||||
}
|
||||
Reference in New Issue
Block a user