* Christian Maurer <dr.ch.mau...@gmail.com> [201210 07:37]: > > // Proof: Set n to a number >= 39 in the following program: > > func main() { > const ( > b = byte(0xc0) > n = 9 > ) > s := []string{string(b)} > for i := 0; i < n; i++ { > s = append(s, []string{""}...) > } > for i := 0; i < n; i++ { > for j := 0; j < len(s[i]); j++ { > s[i+1] += string(s[i][j]) > } > } > println(len(s[n]), len(s[n]) == 1<<(n+1)) > }
Did you try adding fmt.Printf("s[0] = %q len(s[0]) = %d\n", s[0], len(s[0])) after the initial assignment to s? Strings are treated as UTF-8, and string(byte(0xc0)) converts the rune (Unicode code point) '\u00c0' to its UTF-8 representation as a string "\xc3\x80". See https://golang.org/ref/spec#Conversions and scroll down to "Conversions to and from a string type". ...Marvin -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/20201210132104.2v2dsgno647tr3fa%40basil.wdw.