unicodes

package
v0.0.0-...-82e7740 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package unicodes implements unicode utility functions.

Package unicodes implements unicode utility functions.

Package unicodes implements unicode utility functions.

Package unicodes implements unicode utility functions.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func In

func In(r rune, ranges ...*unicode.RangeTable) bool

In reports whether the rune is a member of one of the ranges.

func Is

func Is(rangeTab *unicode.RangeTable, r rune) bool

Is reports whether the rune is in the specified table of ranges.

func IsControl

func IsControl(r rune) bool

IsControl reports whether the rune is a control character. The C (Other) Unicode category includes more code points such as surrogates; use Is(C, r) to test for them.

func IsDigit

func IsDigit(r rune) bool

IsDigit reports whether the rune is a decimal digit.

func IsGraphic

func IsGraphic(r rune) bool

IsGraphic reports whether the rune is defined as a Graphic by Unicode. Such characters include letters, marks, numbers, punctuation, symbols, and spaces, from categories L, M, N, P, S, Zs.

func IsHan

func IsHan(r rune) bool

IsHan reports whether the rune is a Chinese characters.

Example
package main

import (
	"fmt"

	"gopkg.in/goyy/goyy.v0/util/unicodes"
)

func main() {
	fmt.Println(unicodes.IsHan('中'))
	fmt.Println(unicodes.IsHan('文'))
	fmt.Println(unicodes.IsHan('一'))
	fmt.Println(unicodes.IsHan('a'))
	fmt.Println(unicodes.IsHan('A'))
	fmt.Println(unicodes.IsHan('1'))
	fmt.Println(unicodes.IsHan(','))
	fmt.Println(unicodes.IsHan(' '))

}
Output:

true
true
true
false
false
false
false
false

func IsLetter

func IsLetter(r rune) bool

IsLetter reports whether the rune is a letter (category L).

func IsLower

func IsLower(r rune) bool

IsLower reports whether the rune is a lower case letter.

func IsMark

func IsMark(r rune) bool

IsMark reports whether the rune is a mark character (category M).

func IsNumber

func IsNumber(r rune) bool

IsNumber reports whether the rune is a number (category N).

func IsOneOf

func IsOneOf(ranges []*unicode.RangeTable, r rune) bool

IsOneOf reports whether the rune is a member of one of the ranges. The function "In" provides a nicer signature and should be used in preference to IsOneOf.

func IsPrint

func IsPrint(r rune) bool

IsPrint reports whether the rune is defined as printable by Go. Such characters include letters, marks, numbers, punctuation, symbols, and the ASCII space character, from categories L, M, N, P, S and the ASCII space character. This categorization is the same as IsGraphic except that the only spacing character is ASCII space, U+0020.

func IsPunct

func IsPunct(r rune) bool

IsPunct reports whether the rune is a Unicode punctuation character (category P).

func IsQuote

func IsQuote(r rune) bool

IsQuote reports whether the rune is a quote. Returns true when the value of r is ' or " or `, otherwise it returns false.

Example
package main

import (
	"fmt"

	"gopkg.in/goyy/goyy.v0/util/unicodes"
)

func main() {
	fmt.Println(unicodes.IsQuote('"'))
	fmt.Println(unicodes.IsQuote('`'))
	fmt.Println(unicodes.IsQuote('\''))
	fmt.Println(unicodes.IsQuote('a'))
	fmt.Println(unicodes.IsQuote('1'))
	fmt.Println(unicodes.IsQuote('A'))
	fmt.Println(unicodes.IsQuote('一'))
	fmt.Println(unicodes.IsQuote(' '))

}
Output:

true
true
true
false
false
false
false
false

func IsSpace

func IsSpace(r rune) bool

IsSpace reports whether the rune is a space character as defined by Unicode's White Space property; in the Latin-1 space this is

'\t', '\n', '\v', '\f', '\r', ' ', U+0085 (NEL), U+00A0 (NBSP).

Other definitions of spacing characters are set by category Z and property Pattern_White_Space.

func IsSymbol

func IsSymbol(r rune) bool

IsSymbol reports whether the rune is a symbolic character.

func IsTitle

func IsTitle(r rune) bool

IsTitle reports whether the rune is a title case letter.

func IsUpper

func IsUpper(r rune) bool

IsUpper reports whether the rune is an upper case letter.

func SimpleFold

func SimpleFold(r rune) rune

SimpleFold iterates over Unicode code points equivalent under the Unicode-defined simple case folding. Among the code points equivalent to rune (including rune itself), SimpleFold returns the smallest rune > r if one exists, or else the smallest rune >= 0.

For example:

SimpleFold('A') = 'a'
SimpleFold('a') = 'A'

SimpleFold('K') = 'k'
SimpleFold('k') = '\u212A' (Kelvin symbol, K)
SimpleFold('\u212A') = 'K'

SimpleFold('1') = '1'

func To

func To(_case int, r rune) rune

To maps the rune to the specified case: UpperCase, LowerCase, or TitleCase.

func ToLower

func ToLower(r rune) rune

ToLower maps the rune to lower case.

func ToTitle

func ToTitle(r rune) rune

ToTitle maps the rune to title case.

func ToUpper

func ToUpper(r rune) rune

ToUpper maps the rune to upper case.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL