Documentation
¶
Overview ¶
Package uucode is a Go port of jacobsandlund/uucode's core Unicode APIs.
The package uses generated Unicode Character Database tables and exposes string grapheme cluster iteration and terminal cell width helpers.
Index ¶
- func ComputeGraphemeBreak(gb1, gb2 GraphemeBreak, state *BreakState) bool
- func EastAsianWidth(r rune) string
- func EqualFold(s, t string) bool
- func GeneralCategory(r rune) string
- func IsASCIIHexDigit(r rune) bool
- func IsBreak(cp1, cp2 rune, state *BreakState) bool
- func IsControl(r rune) bool
- func IsDash(r rune) bool
- func IsDiacritic(r rune) bool
- func IsDigit(r rune) bool
- func IsEmojiPresentation(r rune) bool
- func IsExtendedPictographic(r rune) bool
- func IsGraphic(r rune) bool
- func IsHexDigit(r rune) bool
- func IsLetter(r rune) bool
- func IsLower(r rune) bool
- func IsMark(r rune) bool
- func IsNoncharacter(r rune) bool
- func IsNumber(r rune) bool
- func IsPatternSyntax(r rune) bool
- func IsPatternWhiteSpace(r rune) bool
- func IsPrint(r rune) bool
- func IsPunct(r rune) bool
- func IsQuotationMark(r rune) bool
- func IsSpace(r rune) bool
- func IsSymbol(r rune) bool
- func IsTitle(r rune) bool
- func IsUnifiedIdeograph(r rune) bool
- func IsUpper(r rune) bool
- func IsVariationSelector(r rune) bool
- func LineBreak(r rune) string
- func RuneWidth(r rune) int
- func SentenceBreak(r rune) string
- func SimpleFold(r rune) rune
- func StringWidth(s string) int
- func ToLower(r rune) rune
- func ToTitle(r rune) rune
- func ToUpper(r rune) rune
- func WordBreak(r rune) string
- type BreakState
- type Grapheme
- type GraphemeBreak
- type GraphemeIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeGraphemeBreak ¶
func ComputeGraphemeBreak(gb1, gb2 GraphemeBreak, state *BreakState) bool
ComputeGraphemeBreak reports whether there is a grapheme cluster boundary between two grapheme break properties, updating state for rules that depend on previous properties.
func EastAsianWidth ¶
EastAsianWidth returns the Unicode East Asian Width abbreviation for r.
func GeneralCategory ¶
GeneralCategory returns the Unicode general category abbreviation for r.
func IsASCIIHexDigit ¶
IsASCIIHexDigit reports whether r has the Unicode ASCII_Hex_Digit property.
func IsBreak ¶
func IsBreak(cp1, cp2 rune, state *BreakState) bool
IsBreak reports whether there is a grapheme cluster boundary between cp1 and cp2, updating state for rules that depend on previous code points.
func IsDiacritic ¶
IsDiacritic reports whether r has the Unicode Diacritic property.
func IsEmojiPresentation ¶
IsEmojiPresentation reports whether r has emoji presentation by default.
func IsExtendedPictographic ¶
IsExtendedPictographic reports whether r has the Extended_Pictographic property.
func IsHexDigit ¶
IsHexDigit reports whether r has the Unicode Hex_Digit property.
func IsNoncharacter ¶
IsNoncharacter reports whether r has the Unicode Noncharacter_Code_Point property.
func IsPatternSyntax ¶
IsPatternSyntax reports whether r has the Unicode Pattern_Syntax property.
func IsPatternWhiteSpace ¶
IsPatternWhiteSpace reports whether r has the Unicode Pattern_White_Space property.
func IsQuotationMark ¶
IsQuotationMark reports whether r has the Unicode Quotation_Mark property.
func IsUnifiedIdeograph ¶
IsUnifiedIdeograph reports whether r has the Unicode Unified_Ideograph property.
func IsVariationSelector ¶
IsVariationSelector reports whether r has the Unicode Variation_Selector property.
func SentenceBreak ¶
SentenceBreak returns the Unicode sentence break property name for r.
func SimpleFold ¶
SimpleFold returns the next rune equivalent to r under simple case folding.
func StringWidth ¶
StringWidth returns the grapheme-aware terminal cell width of s.
The result follows the width rules generated into this package's runtime tables and treats extended grapheme clusters as display units.
Types ¶
type BreakState ¶
type BreakState string
BreakState carries state between adjacent grapheme break decisions.
Most callers should use GraphemeIterator instead of managing BreakState directly.
const ( BreakStateDefault BreakState = "default" BreakStateRegionalIndicator BreakState = "regional_indicator" BreakStateExtendedPictographic BreakState = "extended_pictographic" BreakStateIndicConjunctConsonant BreakState = "indic_conjunct_break_consonant" BreakStateIndicConjunctLinker BreakState = "indic_conjunct_break_linker" )
Grapheme break state values.
type Grapheme ¶
type Grapheme struct {
// Start is the byte offset of the first byte in the grapheme cluster.
Start int
// End is the byte offset just after the grapheme cluster.
End int
}
Grapheme identifies a grapheme cluster by byte offsets into the original string.
type GraphemeBreak ¶
type GraphemeBreak string
GraphemeBreak is a Unicode grapheme break property value.
const ( GraphemeOther GraphemeBreak = "other" GraphemeControl GraphemeBreak = "control" GraphemePrepend GraphemeBreak = "prepend" GraphemeCR GraphemeBreak = "cr" GraphemeLF GraphemeBreak = "lf" GraphemeRegionalIndicator GraphemeBreak = "regional_indicator" GraphemeSpacingMark GraphemeBreak = "spacing_mark" GraphemeL GraphemeBreak = "l" GraphemeV GraphemeBreak = "v" GraphemeT GraphemeBreak = "t" GraphemeLV GraphemeBreak = "lv" GraphemeLVT GraphemeBreak = "lvt" GraphemeZWJ GraphemeBreak = "zwj" GraphemeZWNJ GraphemeBreak = "zwnj" GraphemeExtendedPictographic GraphemeBreak = "extended_pictographic" GraphemeEmojiModifierBase GraphemeBreak = "emoji_modifier_base" GraphemeEmojiModifier GraphemeBreak = "emoji_modifier" GraphemeIndicConjunctExtend GraphemeBreak = "indic_conjunct_break_extend" GraphemeIndicConjunctLinker GraphemeBreak = "indic_conjunct_break_linker" GraphemeIndicConjunctConsonant GraphemeBreak = "indic_conjunct_break_consonant" )
Grapheme break property values.
func GraphemeBreakProperty ¶
func GraphemeBreakProperty(r rune) GraphemeBreak
GraphemeBreakProperty returns the Unicode grapheme break property for r.
type GraphemeIterator ¶
type GraphemeIterator struct {
// contains filtered or unexported fields
}
GraphemeIterator iterates over extended grapheme clusters in a string.
func NewGraphemeIterator ¶
func NewGraphemeIterator(s string) GraphemeIterator
NewGraphemeIterator returns a grapheme cluster iterator for s.
func (*GraphemeIterator) Next ¶
func (it *GraphemeIterator) Next() (Grapheme, bool)
Next returns the next grapheme cluster.
The returned Grapheme contains byte offsets into the original string. ok is false after the iterator is exhausted.
func (GraphemeIterator) Peek ¶
func (it GraphemeIterator) Peek() (Grapheme, bool)
Peek returns the next grapheme cluster without advancing the iterator.