UnicodeVersion is the Unicode version from which the tables in this package are derived.
const UnicodeVersion = "10.0.0"
Kind indicates the type of width property as defined in http://unicode.org/reports/tr11/.
type Kind int
const (
// Neutral characters do not occur in legacy East Asian character sets.
Neutral Kind = iota
// EastAsianAmbiguous characters that can be sometimes wide and sometimes
// narrow and require additional information not contained in the character
// code to further resolve their width.
EastAsianAmbiguous
// EastAsianWide characters are wide in its usual form. They occur only in
// the context of East Asian typography. These runes may have explicit
// halfwidth counterparts.
EastAsianWide
// EastAsianNarrow characters are narrow in its usual form. They often have
// fullwidth counterparts.
EastAsianNarrow
// EastAsianFullwidth characters have a compatibility decompositions of type
// wide that map to a narrow counterpart.
EastAsianFullwidth
// EastAsianHalfwidth characters have a compatibility decomposition of type
// narrow that map to a wide or ambiguous counterpart, plus U+20A9 ₩ WON
// SIGN.
EastAsianHalfwidth
)
func (i Kind) String() string
Properties provides access to width properties of a rune.
type Properties struct {
// contains filtered or unexported fields
}
func Lookup(b []byte) (p Properties, size int)
Lookup reports the Properties of the first rune in b and the number of bytes of its UTF-8 encoding.
func LookupRune(r rune) Properties
LookupRune reports the Properties of rune r.
func LookupString(s string) (p Properties, size int)
LookupString reports the Properties of the first rune in s and the number of bytes of its UTF-8 encoding.
func (p Properties) Folded() rune
Folded returns the folded variant of a rune or 0 if the rune is canonical.
func (p Properties) Kind() Kind
Kind returns the Kind of a rune as defined in Unicode TR #11. See http://unicode.org/reports/tr11/ for more details.
func (p Properties) Narrow() rune
Narrow returns the narrow variant of a rune or 0 if the rune is already narrow or doesn't have a narrow variant.
func (p Properties) Wide() rune
Wide returns the wide variant of a rune or 0 if the rune is already wide or doesn't have a wide variant.
Transformer implements the transform.Transformer interface.
type Transformer struct {
// contains filtered or unexported fields
}
var (
// Fold is a transform that maps all runes to their canonical width.
//
// Note that the NFKC and NFKD transforms in golang.org/x/text/unicode/norm
// provide a more generic folding mechanism.
Fold Transformer = Transformer{foldTransform{}}
// Widen is a transform that maps runes to their wide variant, if
// available.
Widen Transformer = Transformer{wideTransform{}}
// Narrow is a transform that maps runes to their narrow variant, if
// available.
Narrow Transformer = Transformer{narrowTransform{}}
)
▹ Example (Fold)
▹ Example (Narrow)
▹ Example (Widen)
func (t Transformer) Bytes(b []byte) []byte
Bytes returns a new byte slice with the result of applying t to b.
func (t Transformer) Reset()
Reset implements the transform.Transformer interface.
func (t Transformer) Span(src []byte, atEOF bool) (n int, err error)
Span implements the transform.SpanningTransformer interface.
func (t Transformer) String(s string) string
String returns a string with the result of applying t to s.
func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)
Transform implements the transform.Transformer interface.