On Tuesday, July 9, 2024 at 3:42:51 PM UTC-4 David Anderson wrote: I've been going over the spec to clarify finer points of how string vs. []byte behave, I think there may be an unnecessary degree of freedom that could be removed. Either that, or I missed a load-bearing statement that constrains implementations.
In https://go.dev/ref/spec#Conversions, `[]rune(str)` is specified as: "Converting a value of a string type to a slice of runes type yields a slice containing the individual Unicode code points of the string." This does not specify the behavior if the string contains invalid UTF-8 byte sequences. If my reading is correct, a compliant implementation would be free to panic() on such a conversion, or implement the conversion in an arbitrary way of its choosing. - Dave A run-time panic requires explicit mention. UTF-8 is defined by the Unicode Standard: https://www.unicode.org/versions/latest. Does the Unicode Standard allow arbitrary conversion behavior? peter -- 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/d7005b18-e5f0-41ae-bf4c-c6dfe825b7d2n%40googlegroups.com.