×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang unicode.IsSymbol() Function with Examples

Golang | unicode.IsSymbol() Function: Here, we are going to learn about the IsSymbol() function of the unicode package with its usages, syntax, and examples.
Submitted by IncludeHelp, on September 17, 2021

unicode.IsSymbol()

The IsSymbol() function is an inbuilt function of the unicode package which is used to check whether the given rune is a symbolic character.

It accepts one parameter (r rune) and returns true if rune r is a symbolic character; false, otherwise.

Syntax

func IsSymbol(r rune) bool

Parameters

  • r : Rune type value to be checked whether it is a symbolic character or not.

Return Value

The return type of the unicode.IsSymbol() function is a bool, it returns true if rune r is a symbolic character; false, otherwise.

Example 1

// Golang program to demonstrate the
// example of unicode.IsSymbol() Function

package main

import (
	"fmt"
	"unicode"
)

func main() {
	fmt.Println("unicode.IsSymbol('∞'):",
		unicode.IsSymbol('∞'))
	fmt.Println("unicode.IsSymbol('¥'):",
		unicode.IsSymbol('¥'))
	fmt.Println("unicode.IsSymbol('©'):",
		unicode.IsSymbol('©'))
	fmt.Println("unicode.IsSymbol('😀'):",
		unicode.IsSymbol('😀'))
	fmt.Println("unicode.IsSymbol('\\r')",
		unicode.IsSymbol('\r'))
	fmt.Println("unicode.IsSymbol('G'):",
		unicode.IsSymbol('G'))
	fmt.Println("unicode.IsSymbol('\\a'):",
		unicode.IsSymbol('\a'))
}

Output:

unicode.IsSymbol('∞'): true
unicode.IsSymbol('¥'): true
unicode.IsSymbol('©'): true
unicode.IsSymbol('😀'): true
unicode.IsSymbol('\r') false
unicode.IsSymbol('G'): false
unicode.IsSymbol('\a'): false

Example 2

// Golang program to demonstrate the
// example of unicode.IsSymbol() Function

package main

import (
	"fmt"
	"unicode"
)

func main() {
	// constant with mixed type runes
	const mixed = "Hello😀 Guys & Gals! ∞¥©🙈🙉🙊"

	fmt.Println("Symbol characters are:")
	for _, c := range mixed {
		if unicode.IsSymbol(c) == true {
			fmt.Printf("%c", c)
		}
	}
}

Output:

Symbol characters are:
😀∞¥©🙈🙉🙊

Golang unicode Package »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.