Golang unicode.IsControl() function example

package unicode

Golang unicode.IsControl() function usage example. Use to check if the input rune is a ASCII control character. See https://en.wikipedia.org/wiki/Control_character

 package main

 import (
 "fmt"
 "unicode"
 )

 var tab unicode.RangeTable

 func main() {

 control := unicode.IsControl('A')
 fmt.Println("A is a control rune code ? : ", control)

 control = unicode.IsControl('\f')
 fmt.Println("\\f is a control rune code ? : ", control)

 // see https://en.wikipedia.org/wiki/Control_character
 // for the list of control characters
 }

Output :

A is a control rune code ? : false

\f is a control rune code ? : true

Reference :

http://golang.org/pkg/unicode/#IsControl

Advertisement