Documentation ¶
Overview ¶
Package xid implements validation functions for unicode identifiers, as defined in UAX#31: https://unicode.org/reports/tr31/. The syntax for an identifier is:
<identifier> := <xid_start> <xid_continue>*
where <xid_start> and <xid_continue> derive from <id_start> and <id_continue>, respectively, and check their NFKC normalized forms.
Example ¶
isIdent := func(input string) bool { // identifier should be non-empty if input == "" { return false } for i, r := range input { if i == 0 { // first rune should be in xid_start if !Start(r) { return false } } else { // other runes should be in xid_continue if !Continue(r) { return false } } } return true } fmt.Println(isIdent("index")) fmt.Println(isIdent("snake_case")) fmt.Println(isIdent("Δx")) fmt.Println(isIdent("xₒ")) fmt.Println(isIdent("ä")) fmt.Println(isIdent("aᵢ")) fmt.Println(isIdent("मूलधन")) fmt.Println(isIdent("kebab-case")) fmt.Println(isIdent("3x")) fmt.Println(isIdent("_id"))
Output: true true true true true true true false false false
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.