News for hackers. Stuff that matters.
Re:Zig 0.9.0 by skybrian on Monday December 20, 2021 @07:25PM (#29632283)
I’m not aware of any significant breakage due to Go’s handling of strings. Where would I read more about this?
Re:Zig 0.9.0 by noisem4ker on Tuesday December 21, 2021 @02:26PM (#29641059)
Go presents strings as slices of bytes (chars). As long as it's ASCII, it's fine. However, when dealing with multi-byte UTF-8 characters (codepoints), the proper unit is the rune. So, before attempting to measure a string's length, or read its n-th character, one must remember and access the string as a slice of runes.

  s := "naïve"
  
  // bad
  fmt.Println(len(s)) // 6
  fmt.Println(string(s[2])) // Ã
  
  // good
  r := []rune(s)
  fmt.Println(len(r)) // 5
  fmt.Println(string(r[2])) // ï
https://go.dev/play/p/YbMo49wU7vu
Re:Zig 0.9.0 by skybrian on Tuesday December 21, 2021 @09:13PM (#29644804)
Yes, but I think most Go developers are aware of Go's quirks, so I'm wondering what bugs happen despite that awareness.