Documentation
¶
Overview ¶
Package format contains types for defining language-specific formatting of values.
This package is internal now, but will eventually be exposed after the API settles.
Index ¶
Constants ¶
const ( AlwaysSign NumberFormatFlag = 1 << iota AlwaysExpSign AlwaysDecimalSeparator ParenthesisForNegative // Common pattern. Saves space. PadAfterNumber PadAfterAffix PadBeforePrefix = 0 // Default PadAfterPrefix = PadAfterAffix PadBeforeSuffix = PadAfterNumber PadAfterSuffix = PadAfterNumber | PadAfterAffix PadMask = PadAfterNumber | PadAfterAffix )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NumberFormat ¶
type NumberFormat 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 NumberFormatFlag
// Number of digits.
MinIntegerDigits uint8
MaxIntegerDigits uint8
MinFractionDigits uint8
MaxFractionDigits uint8
MinSignificantDigits uint8
MaxSignificantDigits uint8
MinExponentDigits uint8
}
NumberFormat 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.
func ParseNumberPattern ¶
func ParseNumberPattern(s string) (f *NumberFormat, err error)
ParseNumberPattern extracts formatting information from a CLDR number pattern.
See http://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns.
type NumberFormatFlag ¶
type NumberFormatFlag uint8
A NumberFormatFlag is a bit mask for the flag field of a NumberFormat.
type State ¶
type State interface {
fmt.State
// Language reports the requested language in which to render a message.
Language() language.Tag
}
State represents the printer state passed to custom formatters. It provides access to the fmt.State interface and the sentence and language-related context.