Documentation
¶
Index ¶
- func ASCIIDigits(s string) string
- func Between(s string, start, end int) string
- func Center(s string, width int) string
- func DecodeUTF8(data []byte) (string, error)
- func DigitValue(r rune) int
- func DropFirst(s string, n int) string
- func DropLast(s string, n int) string
- func FieldsN(s string, n int) []string
- func First(s string, n int) string
- func Fold(s string) string
- func IsDigits(s string) bool
- func Last(s string, n int) string
- func Lines(s string) []string
- func NormalizeNewlines(s string) string
- func PadLeft(s string, width int) string
- func PadRight(s string, width int) string
- func ParseBool(s string) (value, ok bool)
- func ParseInt(s string) (int64, error)
- func ParseIntAnyScript(s string) (int64, bool)
- func Thousands(n int64) string
- func Title(s string) string
- func TrimBOM[T ~string | ~[]byte](data T) T
- func UpperFirst(s string) string
- func ValidateUTF8[T ~string | ~[]byte](data T) error
- func Wrap(text string, width int, o WrapOptions) []string
- type InvalidUTF8Error
- type WrapOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ASCIIDigits ¶
s with each decimal digit of another script (Arabic-Indic, Devanagari, fullwidth and every other Unicode Nd digit) replaced by the ASCII digit of the same value, everything else kept
func Between ¶
Characters of s from position start up to but not including position end, both counted in characters and kept inside s
func Center ¶
s between runs of spaces that make it width characters long, the odd space going to the right; s itself when it is already that long
func DecodeUTF8 ¶
Text of data when it is valid UTF-8, a leading byte order mark kept, otherwise no text and an *InvalidUTF8Error
func DigitValue ¶
Value 0 to 9 of a decimal digit of any script, its offset in the run of digits around it counted in tens since Unicode encodes every script's digits as ten in a row from zero
func FieldsN ¶
Words of s like strings.Fields, stopping after n words: what follows them is the last item, whole, its leading space cut
func First ¶
First n characters of s, all of s when it has no more and nothing when n is not positive
func Fold ¶
Unicode full case folding of s for caseless matching, ß as ss and every Cherokee letter as the capital Unicode folds it to, which golang.org/x/text/cases alone folds the other way round for the capitals; bytes that are not UTF-8 kept
func Lines ¶
Lines of s without their line ends, split at \n with a \r before it dropped; a line end at the very end starts no empty line
func NormalizeNewlines ¶
s with every CRLF pair and every lone CR turned into LF
func PadLeft ¶
s after the spaces that make it width characters long, s itself when it is already that long
func PadRight ¶
s followed by the spaces that make it width characters long, s itself when it is already that long
func ParseBool ¶
Truth value of a yes or no word: 1, true, yes or on and 0, false, no or off in any letter case, white space around ignored; ok is false for any other text
func ParseInt ¶
Whole number s writes in base ten, white space around it, a leading sign and single underscores between digits allowed; otherwise a *strconv.NumError, its ErrRange coming with the value clamped to the int64 bounds
func ParseIntAnyScript ¶
Whole number s writes in base ten as ParseInt reads it, digits of any script taken for their values; false for anything else and for a value past the int64 range
func Title ¶
s with the first letter of each word in title case and the word's other letters in lower case, a word being a run of letters and numbers with its marks and any apostrophe between letters
func UpperFirst ¶
s with its first character in title case and the rest left as it is
func ValidateUTF8 ¶
Nil when data is valid UTF-8, otherwise an *InvalidUTF8Error at its first invalid byte
Types ¶
type InvalidUTF8Error ¶
type InvalidUTF8Error struct {
// Byte offset of the first byte that starts no valid UTF-8 sequence
Offset int
}
Error for text that is not valid UTF-8, located at its first invalid byte
func (*InvalidUTF8Error) Error ¶
func (e *InvalidUTF8Error) Error() string
Message naming the byte offset where the valid UTF-8 ends
type WrapOptions ¶
type WrapOptions struct {
// Prefix of the first line, counted in its width
Indent string
// Prefix of every line after the first, counted in its width
NextIndent string
// Compound words stay whole instead of breaking after their hyphens
NoHyphenBreaks bool
// A word longer than a line stays whole on a line of its own instead of being cut
KeepLongWords bool
// Line breaks, vertical tabs and form feeds stay as they are instead of each becoming a space
KeepWhitespace bool
}
Settings of Wrap, the zero value filling plain paragraphs