diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index 7634707b3c..f24a071d14 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -23,7 +23,7 @@ func equalPortable(a, b []byte) bool { return true } -// explode splits s into a slice of UTF-8 sequences, one per Unicode character (still slices of bytes), +// explode splits s into a slice of UTF-8 sequences, one per Unicode code point (still slices of bytes), // up to a maximum of n byte slices. Invalid UTF-8 sequences are chopped into individual bytes. func explode(s []byte, n int) [][]byte { if n <= 0 { @@ -47,6 +47,7 @@ func explode(s []byte, n int) [][]byte { } // Count counts the number of non-overlapping instances of sep in s. +// If sep is an empty slice, Count returns 1 + the number of Unicode code points in s. func Count(s, sep []byte) int { n := len(sep) if n == 0 { diff --git a/src/strings/strings.go b/src/strings/strings.go index 27d384983e..f362f185a9 100644 --- a/src/strings/strings.go +++ b/src/strings/strings.go @@ -78,6 +78,7 @@ func hashStrRev(sep string) (uint32, uint32) { } // Count counts the number of non-overlapping instances of sep in s. +// If sep is an empty string, Count returns 1 + the number of Unicode code points in s. func Count(s, sep string) int { n := 0 // special cases