github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/testdata/string.go (about)

     1  package main
     2  
     3  func testRangeString() {
     4  	for i, c := range "abcü¢€𐍈°x" {
     5  		println(i, c)
     6  	}
     7  }
     8  
     9  func testStringToRunes() {
    10  	var s = "abcü¢€𐍈°x"
    11  	for i, c := range []rune(s) {
    12  		println(i, c)
    13  	}
    14  }
    15  
    16  func testRunesToString(r []rune) {
    17  	println("string from runes:", string(r))
    18  }
    19  
    20  type myString string
    21  
    22  func main() {
    23  	testRangeString()
    24  	testStringToRunes()
    25  	testRunesToString([]rune{97, 98, 99, 252, 162, 8364, 66376, 176, 120})
    26  	var _ = len([]byte(myString("foobar"))) // issue 1246
    27  }