From 86dc5b5b23fddc8a8fe44bc35f19a882cd1fe32a Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 28 Oct 2021 14:05:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++-- base14.go | 4 ++-- base14_test.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b9ac2a6..43e462e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ base16384 interface of golang ## Functions +### func EncodeString(b string) []byte +Encode string b to utf16be. +### func DecodeString(d []byte) string +Decode to string from encoded b. ### func Encode(b []byte) []byte Encode b to utf16be. ### func Decode(b []byte) []byte @@ -11,8 +15,6 @@ Decode from encoded b. Display the result. ### func UTF82utf16be(b []byte) ([]byte, error) Turn the result to its original coding form to decode. -### func Free(b []byte) -Free memory allocated by encode / decode. # Usage ## As package diff --git a/base14.go b/base14.go index cc9cca5..06e6d15 100644 --- a/base14.go +++ b/base14.go @@ -13,8 +13,8 @@ func EncodeString(s string) []byte { return Encode(helper.StringToBytes(s)) } -func DecodeString(s string) []byte { - return Decode(helper.StringToBytes(s)) +func DecodeString(d []byte) string { + return helper.BytesToString(Decode(d)) } func Encode(b []byte) (encd []byte) { diff --git a/base14_test.go b/base14_test.go index ad80ad3..df5a827 100644 --- a/base14_test.go +++ b/base14_test.go @@ -13,7 +13,7 @@ func TestBase14(t *testing.T) { d, err := UTF82utf16be(es) if string(d) == string(e) { if err == nil { - ds := string(Decode(d)) + ds := DecodeString(d) t.Log(ds) if ds != teststr { t.Fail()