1
0
mirror of https://github.com/fumiama/unibase2n.git synced 2026-06-11 04:10:24 +08:00

优化性能

This commit is contained in:
源文雨
2022-09-30 23:01:22 +08:00
parent 71948481ee
commit ec2f2580cf
7 changed files with 93 additions and 67 deletions

12
conv.go
View File

@@ -16,7 +16,7 @@ func UTF82UTF16BE(b []byte) ([]byte, error) {
return format.NewEncoder().Bytes(b)
}
func (bs *Base) EncodeToString(b []byte) string {
func (bs Base) EncodeToString(b []byte) string {
out, err := UTF16BE2UTF8(bs.Encode(b))
if err != nil {
return ""
@@ -24,11 +24,11 @@ func (bs *Base) EncodeToString(b []byte) string {
return BytesToString(out)
}
func (bs *Base) EncodeFromString(s string) []byte {
func (bs Base) EncodeFromString(s string) []byte {
return bs.Encode(StringToBytes(s))
}
func (bs *Base) EncodeString(s string) string {
func (bs Base) EncodeString(s string) string {
out, err := UTF16BE2UTF8(bs.Encode(StringToBytes(s)))
if err != nil {
return ""
@@ -36,11 +36,11 @@ func (bs *Base) EncodeString(s string) string {
return BytesToString(out)
}
func (bs *Base) DecodeToString(d []byte) string {
func (bs Base) DecodeToString(d []byte) string {
return BytesToString(bs.Decode(d))
}
func (bs *Base) DecodeFromString(s string) []byte {
func (bs Base) DecodeFromString(s string) []byte {
d, err := UTF82UTF16BE(StringToBytes(s))
if err != nil {
return nil
@@ -48,7 +48,7 @@ func (bs *Base) DecodeFromString(s string) []byte {
return bs.Decode(d)
}
func (bs *Base) DecodeString(s string) string {
func (bs Base) DecodeString(s string) string {
d, err := UTF82UTF16BE(StringToBytes(s))
if err != nil {
return ""