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, line break opportunity iteration, and terminal cell width helpers.
Index ¶
- func ComputeGraphemeBreak(gb1, gb2 GraphemeBreak, state *BreakState) bool
- func EqualFold(s, t string) bool
- 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 IsEmojiVariationBase(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 RuneWidth(r rune) int
- 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
- type BreakState
- type EastAsianWidthClass
- type GeneralCategoryClass
- type Grapheme
- type GraphemeBreak
- type GraphemeIterator
- type GraphemeWidthIterator
- type GraphemeWithWidth
- type LineBreakClass
- type LineBreakKind
- type LineIterator
- type LineSegment
- type SentenceBreakClass
- type WordBreakClass
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 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 IsEmojiVariationBase ¶ added in v1.1.0
IsEmojiVariationBase reports whether r is a base for an emoji variation sequence.
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 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 uint8
BreakState carries state between adjacent grapheme break decisions.
Most callers should use GraphemeIterator instead of managing BreakState directly.
const ( BreakStateDefault BreakState = iota BreakStateRegionalIndicator BreakStateExtendedPictographic BreakStateIndicConjunctConsonant BreakStateIndicConjunctLinker )
Grapheme break state values.
func (BreakState) String ¶ added in v1.0.2
func (state BreakState) String() string
String returns the state name for state.
type EastAsianWidthClass ¶ added in v1.0.2
type EastAsianWidthClass uint8
EastAsianWidthClass is a Unicode East_Asian_Width property value.
const ( EastAsianWidthN EastAsianWidthClass = iota EastAsianWidthNa EastAsianWidthA EastAsianWidthW EastAsianWidthH EastAsianWidthF )
Unicode East_Asian_Width property values.
func EastAsianWidth ¶
func EastAsianWidth(r rune) EastAsianWidthClass
EastAsianWidth returns the Unicode East Asian Width property for r.
func (EastAsianWidthClass) String ¶ added in v1.0.2
func (eaw EastAsianWidthClass) String() string
String returns the Unicode East_Asian_Width abbreviation for eaw.
type GeneralCategoryClass ¶ added in v1.0.2
type GeneralCategoryClass uint8
GeneralCategoryClass is a Unicode General_Category property value.
const ( GeneralCategoryCn GeneralCategoryClass = iota GeneralCategoryCc GeneralCategoryZs GeneralCategoryPo GeneralCategorySc GeneralCategoryPs GeneralCategoryPe GeneralCategorySm GeneralCategoryPd GeneralCategoryNd GeneralCategoryLu GeneralCategorySk GeneralCategoryPc GeneralCategoryLl GeneralCategorySo GeneralCategoryLo GeneralCategoryPi GeneralCategoryCf GeneralCategoryNo GeneralCategoryPf GeneralCategoryLt GeneralCategoryLm GeneralCategoryMn GeneralCategoryMe GeneralCategoryMc GeneralCategoryNl GeneralCategoryZl GeneralCategoryZp GeneralCategoryCs GeneralCategoryCo )
Unicode General_Category property values.
func GeneralCategory ¶
func GeneralCategory(r rune) GeneralCategoryClass
GeneralCategory returns the Unicode general category for r.
func (GeneralCategoryClass) String ¶ added in v1.0.2
func (gc GeneralCategoryClass) String() string
String returns the Unicode General_Category abbreviation for gc.
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 uint8
GraphemeBreak is a Unicode grapheme break property value.
const ( GraphemeOther GraphemeBreak = iota GraphemeControl GraphemePrepend GraphemeCR GraphemeLF GraphemeRegionalIndicator GraphemeSpacingMark GraphemeL GraphemeV GraphemeT GraphemeLV GraphemeLVT GraphemeZWJ GraphemeZWNJ GraphemeExtendedPictographic GraphemeEmojiModifierBase GraphemeEmojiModifier GraphemeIndicConjunctExtend GraphemeIndicConjunctLinker GraphemeIndicConjunctConsonant )
Grapheme break property values.
func GraphemeBreakProperty ¶
func GraphemeBreakProperty(r rune) GraphemeBreak
GraphemeBreakProperty returns the Unicode grapheme break property for r.
func (GraphemeBreak) String ¶ added in v1.0.2
func (gb GraphemeBreak) String() string
String returns the Unicode grapheme break property name for gb.
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.
type GraphemeWidthIterator ¶ added in v1.2.0
type GraphemeWidthIterator struct {
// contains filtered or unexported fields
}
GraphemeWidthIterator iterates over extended grapheme clusters in a string and computes each cluster's terminal cell width in the same pass.
func NewGraphemeWidthIterator ¶ added in v1.2.0
func NewGraphemeWidthIterator(s string) GraphemeWidthIterator
NewGraphemeWidthIterator returns a grapheme cluster iterator for s that also computes display width for each cluster.
func (*GraphemeWidthIterator) Next ¶ added in v1.2.0
func (it *GraphemeWidthIterator) Next() (GraphemeWithWidth, bool)
Next returns the next grapheme cluster with its terminal cell width.
The returned GraphemeWithWidth contains byte offsets into the original string. ok is false after the iterator is exhausted.
func (GraphemeWidthIterator) Peek ¶ added in v1.2.0
func (it GraphemeWidthIterator) Peek() (GraphemeWithWidth, bool)
Peek returns the next grapheme cluster with width without advancing the iterator.
type GraphemeWithWidth ¶ added in v1.2.0
type GraphemeWithWidth 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
// Width is the terminal cell width of the grapheme cluster.
Width int
}
GraphemeWithWidth identifies a grapheme cluster by byte offsets and includes its terminal cell width.
type LineBreakClass ¶ added in v1.0.2
type LineBreakClass uint8
LineBreakClass is a Unicode Line_Break property value.
const ( LineBreakXX LineBreakClass = iota LineBreakCM LineBreakBA LineBreakLF LineBreakBK LineBreakCR LineBreakSP LineBreakEX LineBreakQU LineBreakAL LineBreakPR LineBreakPO LineBreakOP LineBreakCP LineBreakIS LineBreakHY LineBreakSY LineBreakNU LineBreakCL LineBreakNL LineBreakGL LineBreakAI LineBreakBB LineBreakHH LineBreakHL LineBreakSA LineBreakJL LineBreakJV LineBreakJT LineBreakNS LineBreakAK LineBreakVI LineBreakAS LineBreakID LineBreakVF LineBreakZW LineBreakZWJ LineBreakB2 LineBreakIN LineBreakWJ LineBreakEB LineBreakCJ LineBreakH2 LineBreakH3 LineBreakSG LineBreakCB LineBreakAP LineBreakRI LineBreakEM )
Unicode Line_Break property values.
func LineBreak ¶
func LineBreak(r rune) LineBreakClass
LineBreak returns the Unicode line break property for r.
func (LineBreakClass) String ¶ added in v1.0.2
func (lb LineBreakClass) String() string
String returns the Unicode Line_Break abbreviation for lb.
type LineBreakKind ¶ added in v1.0.2
type LineBreakKind uint8
LineBreakKind describes the line break opportunity after a line segment.
const ( // LineDontBreak means a line must not be broken at this boundary. LineDontBreak LineBreakKind = iota // LineCanBreak means a line may be broken at this boundary. LineCanBreak // LineMustBreak means a line must be broken at this boundary. LineMustBreak )
Line break opportunity values.
func (LineBreakKind) String ¶ added in v1.0.2
func (kind LineBreakKind) String() string
String returns the line break opportunity name for kind.
type LineIterator ¶ added in v1.0.2
type LineIterator struct {
// contains filtered or unexported fields
}
LineIterator iterates over non-breaking line segments in a string according to the Unicode Line Breaking Algorithm (UAX #14).
func NewLineIterator ¶ added in v1.0.2
func NewLineIterator(s string) LineIterator
NewLineIterator returns a line break iterator for s.
func (*LineIterator) Next ¶ added in v1.0.2
func (it *LineIterator) Next() (LineSegment, bool)
Next returns the next non-breaking line segment.
The returned LineSegment contains byte offsets into the original string. ok is false after the iterator is exhausted. In accordance with UAX #14 LB3, the final segment is returned with Break set to LineMustBreak.
func (LineIterator) Peek ¶ added in v1.0.2
func (it LineIterator) Peek() (LineSegment, bool)
Peek returns the next line segment without advancing the iterator.
type LineSegment ¶ added in v1.0.2
type LineSegment struct {
// Start is the byte offset of the first byte in the segment.
Start int
// End is the byte offset just after the segment.
End int
// Break is the line break opportunity after End.
Break LineBreakKind
}
LineSegment identifies a non-breaking line segment by byte offsets into the original string. Break describes the line break opportunity after End.
type SentenceBreakClass ¶ added in v1.0.2
type SentenceBreakClass uint8
SentenceBreakClass is a Unicode Sentence_Break property value.
const ( SentenceBreakOther SentenceBreakClass = iota SentenceBreakSp SentenceBreakLF SentenceBreakCR SentenceBreakSTerm SentenceBreakClose SentenceBreakSContinue SentenceBreakATerm SentenceBreakNumeric SentenceBreakUpper SentenceBreakLower SentenceBreakSep SentenceBreakFormat SentenceBreakOLetter SentenceBreakExtend )
Unicode Sentence_Break property values.
func SentenceBreak ¶
func SentenceBreak(r rune) SentenceBreakClass
SentenceBreak returns the Unicode sentence break property for r.
func (SentenceBreakClass) String ¶ added in v1.0.2
func (sb SentenceBreakClass) String() string
String returns the Unicode Sentence_Break property name for sb.
type WordBreakClass ¶ added in v1.0.2
type WordBreakClass uint8
WordBreakClass is a Unicode Word_Break property value.
const ( WordBreakOther WordBreakClass = iota WordBreakLF WordBreakNewline WordBreakCR WordBreakWSegSpace WordBreakDoubleQuote WordBreakSingleQuote WordBreakMidNum WordBreakMidNumLet WordBreakNumeric WordBreakMidLetter WordBreakALetter WordBreakExtendNumLet WordBreakFormat WordBreakExtend WordBreakHebrewLetter WordBreakZWJ WordBreakKatakana WordBreakRegionalIndicator )
Unicode Word_Break property values.
func WordBreak ¶
func WordBreak(r rune) WordBreakClass
WordBreak returns the Unicode word break property for r.
func (WordBreakClass) String ¶ added in v1.0.2
func (wb WordBreakClass) String() string
String returns the Unicode Word_Break property name for wb.