Home »
Golang »
Golang Reference
Golang unicode.In() Function with Examples
Golang | unicode.In() Function: Here, we are going to learn about the In() function of the unicode package with its usages, syntax, and examples.
Submitted by IncludeHelp, on September 16, 2021
unicode.In()
The In() function is an inbuilt function of the unicode package which is used to check whether the given rune is a member of one of the given ranges.
It accepts two or more parameters (r rune, ranges ...*RangeTable) and returns true if rune r is a member of one of the given ranges; false, otherwise.
Syntax
func In(r rune, ranges ...*RangeTable) bool
Parameters
- r : Rune type value to be checked as a member of the ranges.
- ranges... : One or more ranges in which rune r to be checked.
Return Value
The return type of the unicode.In() function is bool, it returns true if rune r is a member of one of the given ranges; false, otherwise.
Example 1
// Golang program to demonstrate the
// example of unicode.In() Function
package main
import (
"fmt"
"unicode"
)
func main() {
result := unicode.In('A', unicode.Latin)
fmt.Println(result)
result = unicode.In('Ɐ', unicode.Latin)
fmt.Println(result)
result = unicode.In('&', unicode.Latin)
fmt.Println(result)
}
Output:
true
true
false
Example 2
// Golang program to demonstrate the
// example of unicode.In() Function
package main
import (
"fmt"
"unicode"
)
func main() {
fmt.Println("unicode.In('x', unicode.Latin):",
unicode.In('x', unicode.Latin))
fmt.Println("unicode.In('F', unicode.ASCII_Hex_Digit):",
unicode.In('F', unicode.ASCII_Hex_Digit))
fmt.Println("unicode.In('\\t', unicode.White_Space):",
unicode.In('\t', unicode.White_Space))
fmt.Println("unicode.In('\\a', unicode.White_Space):",
unicode.In('\a', unicode.White_Space))
}
Output:
unicode.In('x', unicode.Latin): true
unicode.In('F', unicode.ASCII_Hex_Digit): true
unicode.In('\t', unicode.White_Space): true
unicode.In('\a', unicode.White_Space): false
Example 3:
// Golang program to demonstrate the
// example of unicode.In() Function
package main
import (
"fmt"
"unicode"
)
func main() {
fmt.Println("unicode.In('F', unicode.Latin,unicode.ASCII_Hex_Digit):",
unicode.In('x', unicode.Latin, unicode.ASCII_Hex_Digit))
fmt.Println("unicode.In('Ɐ', unicode.Latin,unicode.ASCII_Hex_Digit):",
unicode.In('Ɐ', unicode.Latin, unicode.ASCII_Hex_Digit))
fmt.Println("unicode.In(' ', unicode.Latin,unicode.ASCII_Hex_Digit):",
unicode.In(' ', unicode.Latin, unicode.ASCII_Hex_Digit))
}
Output:
unicode.In('F', unicode.Latin,unicode.ASCII_Hex_Digit): true
unicode.In('Ɐ', unicode.Latin,unicode.ASCII_Hex_Digit): true
unicode.In(' ', unicode.Latin,unicode.ASCII_Hex_Digit): false
Golang unicode Package »