import "golang.org/x/text/internal/number"
Package number contains tools and data for formatting numbers.
common.go number.go pattern.go plural.go tables.go
const CLDRVersion = "28"CLDRVersion is the CLDR version from which the tables in this package are derived.
type Format struct {
Affix string // includes prefix and suffix. First byte is prefix length.
Offset uint16 // Offset into Affix for prefix and suffix
NegOffset uint16 // Offset into Affix for negative prefix and suffix or 0.
Multiplier uint32
RoundIncrement uint32 // Use Min*Digits to determine scale
PadRune rune
FormatWidth uint16
GroupingSize [2]uint8
Flags FormatFlag
// Number of digits.
MinIntegerDigits uint8
MaxIntegerDigits uint8
MinFractionDigits uint8
MaxFractionDigits uint8
MinSignificantDigits uint8
MaxSignificantDigits uint8
MinExponentDigits uint8
}Format holds information for formatting numbers. It is designed to hold information from CLDR number patterns.
This pattern is precompiled for all patterns for all languages. Even though the number of patterns is not very large, we want to keep this small.
This type is only intended for internal use.
ParsePattern extracts formatting information from a CLDR number pattern.
See http://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns.
A FormatFlag is a bit mask for the flag field of a Format.
const (
AlwaysSign FormatFlag = 1 << iota
AlwaysExpSign
AlwaysDecimalSeparator
ParenthesisForNegative // Common pattern. Saves space.
PadAfterNumber
PadAfterAffix
PadBeforePrefix = 0 // Default
PadAfterPrefix = PadAfterAffix
PadBeforeSuffix = PadAfterNumber
PadAfterSuffix = PadAfterNumber | PadAfterAffix
PadMask = PadAfterNumber | PadAfterAffix
)type Info struct {
// contains filtered or unexported fields
}Info holds number formatting configuration data.
InfoFromLangID returns a Info for the given compact language identifier and numbering system identifier. If system is the empty string, the default numbering system will be taken for that language.
InfoFromTag returns a Info for the given language tag.
Digit returns the digit for the numbering system for the corresponding ASCII value. For example, ni.Digit('3') could return '三'. Note that the argument is the rune constant '3', which equals 51, not the integer constant 3.
IsDecimal reports if the numbering system can convert decimal to native symbols one-to-one.
func (n Info) Symbol(t SymbolType) string
Symbol returns the string for the given symbol type.
WriteDigit writes the UTF-8 sequence for n corresponding to the given ASCII digit to dst and reports the number of bytes written. dst must be large enough to hold the rune (can be up to utf8.UTFMax bytes).
A SymbolType identifies a symbol of a specific kind.
const (
SymDecimal SymbolType = iota
SymGroup
SymList
SymPercentSign
SymPlusSign
SymMinusSign
SymExponential
SymSuperscriptingExponent
SymPerMille
SymInfinity
SymNan
SymTimeSeparator
NumSymbolTypes
)Package number imports 6 packages (graph). Updated about 5 hours ago. Refresh now. Tools for package owners.