github.com/rolandhe/saber@v0.0.4/example/string/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/rolandhe/saber/jcomp"
     6  	"github.com/rolandhe/saber/utils/strutil"
     7  )
     8  
     9  func main() {
    10  	javaLength()
    11  	//getChan()
    12  	//quickString()
    13  }
    14  
    15  //func getChan() {
    16  //	ch := make(chan int, 2)
    17  //	ch <- 1
    18  //	ch <- 2
    19  //	close(ch)
    20  //	v, c := <-ch
    21  //	fmt.Println(v, c)
    22  //	v, c = <-ch
    23  //	fmt.Println(v, c)
    24  //	v, c = <-ch
    25  //	fmt.Println(v, c)
    26  //}
    27  
    28  func javaLength() {
    29  	s := "刘德华 andi lou"
    30  	l, _ := jcomp.JavaStringLen(s)
    31  
    32  	fmt.Println(l, len(s), strutil.GetRuneLenOfString(s))
    33  }
    34  
    35  func quickString() {
    36  	s := "刘德华 andi lou"
    37  	b := strutil.DetachBytesString(s)
    38  	s1 := strutil.AttachBytesString(b)
    39  	fmt.Println(s1)
    40  }