- This library provides the method encode string to uint16 array and the method decode uint16 array to string. What's more, this library includes some simple funtion like
Count
,Index
,Join
of uint16 array. - The encode and decode method is efficient. And the process just need one memory allocation.
- encode string to uint16 array like this.
package main
import (
"fmt"
"github.com/lianggx6/goutf16"
)
func main() {
content := goutf16.EncodeStringToUTF16("你好")
fmt.Println(content)
}
- decode uint16 array to string like this
package main
import (
"fmt"
"github.com/lianggx6/goutf16"
)
func main() {
content := goutf16.DecodeUTF16ToString([]uint16{20320, 22909})
fmt.Println(content)
}