Standard library / unicode/utf8
utf8.Valid()
Reports whether all input bytes are valid UTF-8. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func Valid(p []byte) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| p | []byte | Byte sequence or destination buffer, as specified. |
Return Value
bool
Reports whether all input bytes are valid UTF-8.
Working Example
Example Snippetgo
package main
import ( "fmt" "unicode/utf8")
func main() { fmt.Println(utf8.Valid([]byte("é")), utf8.Valid([]byte{0xff}))}