You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
387 B
Go

package startext
import (
"fmt"
"testing"
)
func Test_Gbk(t *testing.T) {
str:="你好"
if IsGBK([]byte(str)) {
t.Fail()
}
if !IsUtf8([]byte(str)) {
t.Fail()
}
gbk,err:=UTF82GBK([]byte(str))
if err!=nil{
t.Fatal(err)
}
if !IsGBK(gbk) {
t.Fail()
}
if IsUtf8(gbk) {
t.Fail()
}
utf8,err:=GBK2UTF8(gbk)
if err!=nil{
t.Fatal(err)
}
fmt.Println(string(utf8))
}