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) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | rune | Unicode 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))}