Standard library / unicode/utf8

utf8.ValidRune()

Reports whether r is a legal Unicode scalar value, excluding surrogates and out-of-range values. Expected stdout: 'true false\n'.

Formal Syntax & Structure

go syntaxgo
func ValidRune(r rune) bool

Parameters & Attributes

NameTypeDescription
rruneUnicode code point.

Return Value

bool

Reports whether r is a legal Unicode scalar value, excluding surrogates and out-of-range values.

Working Example

Example Snippetgo
package main
import (  "fmt"  "unicode/utf8")
func main() {  fmt.Println(utf8.ValidRune('é'), utf8.ValidRune(0xd800))}
Go Reference