Rune is a superset of ASCII or it is an alias of int32. It holds all the characters available in the world’s writing system, including accents and other diacritical marks, control codes like tab and carriage return, and assigns each one a standard number. This standard number is known as a Unicode code point or rune in the Go language.
You are allowed to check the given rune is an upper case letter or not with the help of IsUpper() function. This function returns true if the given rune is an upper case letter, or return false if the given rune is not an upper case letter. This function is defined under Unicode package, so for accessing this method you need to import the Unicode package in your program.
Syntax:
func IsUpper(r rune) bool
The return type of this function is boolean. Let us discuss this concept with the help of given examples:
Example 1:
package main
import (
"fmt"
"unicode"
)
func main() {
rune_1 := 'g'
rune_2 := 'e'
rune_3 := 'E'
rune_4 := 'k'
rune_5 := 'S'
res_1 := unicode.IsUpper(rune_1)
res_2 := unicode.IsUpper(rune_2)
res_3 := unicode.IsUpper(rune_3)
res_4 := unicode.IsUpper(rune_4)
res_5 := unicode.IsUpper(rune_5)
fmt.Println(res_1)
fmt.Println(res_2)
fmt.Println(res_3)
fmt.Println(res_4)
fmt.Println(res_5)
}
|
Output:
false
false
true
false
true
Example 2:
package main
import (
"fmt"
"unicode"
)
func main() {
val := []rune{ 'g' , 'E' , 'e' , 'K' , 's' }
for i := 0; i < len(val); i++ {
if unicode.IsUpper(val[i]) == true {
fmt.Printf( "\n%c is an uppercase letter" , val[i])
} else {
fmt.Printf( "\n%c is not an uppercase letter" , val[i])
}
}
}
|
Output:
g is not an uppercase letter
E is an uppercase letter
e is not an uppercase letter
K is an uppercase letter
s is not an uppercase letter
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
27 Sep, 2019
Like Article
Save Article