Standard library / unicode/utf8
utf8.RuneCount()
Counts decoded runes in bytes, counting each invalid byte as one error rune. Not a grapheme count. Expected stdout: '2\n'.
Formal Syntax & Structure
go syntaxgo
func RuneCount(p []byte) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| p | []byte | Byte sequence or destination buffer, as specified. |
Return Value
int
Counts decoded runes in bytes, counting each invalid byte as one error rune. Not a grapheme count.
Working Example
Example Snippetgo
package main
import ( "fmt" "unicode/utf8")
func main() { fmt.Println(utf8.RuneCount([]byte("é!")))}