Documentation
¶
Index ¶
- Constants
- func All(s string, pred func(rune) bool) bool
- func AppendRune(p []byte, r rune) []byte
- func BoolToken(s string) (value, ok bool)
- func BytesFromHex(s string) ([]byte, error)
- func Capitalize(s string) string
- func Casefold(s string) string
- func Center(s string, width int) string
- func DecimalValue(r rune) (int, bool)
- func DecodeASCIIReplace(b []byte) string
- func DecodeLastRune(s string) (rune, int)
- func DecodeRune(s string) (rune, int)
- func DecodeUTF8(raw []byte) (string, error)
- func DecodeUTF8Replace(b []byte) string
- func DecodeUTF8Sig(raw []byte) (string, error)
- func DecodeUTF8SigFile(raw []byte) (string, error)
- func DecodeUTF8SigIgnore(b []byte) string
- func DecodeUTF8SigReplace(b []byte) string
- func EncodeUTF8BackslashReplace(s string) string
- func EncodeUTF8Replace(s string) []byte
- func FirstUnencodableSurrogate(s string) (rune, bool)
- func FromRunes(rs []rune) string
- func GroupThousands(n int64) string
- func IntText(s string) (*big.Int, bool)
- func IsAlnum(r rune) bool
- func IsAlpha(r rune) bool
- func IsCaseIgnorable(r rune) bool
- func IsCased(r rune) bool
- func IsDecimal(r rune) bool
- func IsDigit(r rune) bool
- func IsIdentifier(s string) bool
- func IsPrintable(r rune) bool
- func IsSpace(r rune) bool
- func IsSurrogate(r rune) bool
- func IsUpper(s string) bool
- func IsXIDContinue(r rune) bool
- func IsXIDStart(r rune) bool
- func Len(s string) int
- func Ljust(s string, width int) string
- func Lower(s string) string
- func Lstrip(s string) string
- func LstripChars(s, chars string) string
- func Rjust(s string, width int) string
- func Rstrip(s string) string
- func RstripChars(s, chars string) string
- func Runes(s string) []rune
- func Slice(s string, start, end int) string
- func SplitWhitespace(s string, maxsplit int) []string
- func Splitlines(s string, keepends bool) []string
- func StrIsDigit(s string) bool
- func StrictUTF8EncodeError(s string) error
- func Strip(s string) string
- func StripChars(s, chars string) string
- func SurrogateAt[T WTF8Text](s T, i int) bool
- func SurrogateEscapeDecode(b []byte) string
- func SurrogateEscapeEncode(s string) ([]byte, error)
- func SurrogateRune[T WTF8Text](s T, i int) rune
- func TextwrapWrap(text string, o TextwrapOptions) []string
- func TextwrapWrapNoHyphenBreak(text string, width int, breakLongWords bool) []string
- func Title(s string) string
- func TranslateNewlines(s string) string
- func UTF8DecodeError(data []byte, pos int) error
- func UTF8MaximalSubpart(b []byte) int
- func Upper(s string) string
- func ValidIndex(data []byte) (int, bool)
- func WriteRune(b *strings.Builder, r rune)
- type TextwrapOptions
- type UnicodeDecodeError
- type UnicodeEncodeError
- type WTF8Text
Constants ¶
const ( SurrogateMin = 0xD800 SurrogateHighMax = 0xDBFF SurrogateLowMin = 0xDC00 SurrogateMax = 0xDFFF SurrogateEscapeMin = 0xDC80 SurrogateEscapeMax = 0xDCFF )
Surrogate code point bounds and the range a surrogateescape decode produces
Variables ¶
This section is empty.
Functions ¶
func All ¶
Whole string form of a per code point predicate, false for the empty string like the str methods
func AppendRune ¶
Appends r encoded as generalized UTF-8 so a surrogate keeps its own three bytes
func BoolToken ¶
True or false for a recognized truthy or falsy token after strip and lower, ok false for anything else
func BytesFromHex ¶
Bytes of hex digit pairs with ASCII whitespace allowed between pairs, the ValueError of bytes fromhex otherwise
func Capitalize ¶
str.capitalize, the first code point in title case and the rest lowered
func Casefold ¶
str.casefold with full case folding, Cherokee folding to its uppercase letters as CaseFolding.txt maps it
func DecimalValue ¶
Numeric value of a Unicode decimal digit as Python int parses it, false for any other rune
func DecodeASCIIReplace ¶
Decodes bytes as ascii with every byte above 127 replaced by U+FFFD
func DecodeLastRune ¶
Trailing code point and its byte size with the same surrogate rules as the forward decode
func DecodeRune ¶
Leading code point and its byte size, surrogates whole and each stray invalid byte as its surrogateescape char
func DecodeUTF8 ¶
Text of bytes under a strict utf-8 decode that keeps a leading BOM, the UnicodeDecodeError on invalid input
func DecodeUTF8Replace ¶
bytes.decode utf-8 with errors replace, one U+FFFD per maximal invalid subpart
func DecodeUTF8Sig ¶
Text of utf-8-sig bytes, one leading BOM dropped, the strict UnicodeDecodeError on invalid UTF-8
func DecodeUTF8SigFile ¶
Text of a whole utf-8-sig file read, a lone BOM start reading as empty
func DecodeUTF8SigIgnore ¶
Decodes utf-8-sig with errors ignore, the BOM stripped and every undecodable byte run dropped
func DecodeUTF8SigReplace ¶
Decodes utf-8-sig with errors replace, the BOM stripped and each undecodable run shown as U+FFFD
func EncodeUTF8BackslashReplace ¶
UTF-8 text of s like str.encode with errors backslashreplace, each lone surrogate becoming a backslash u escape
func EncodeUTF8Replace ¶
UTF-8 bytes of s like str.encode with errors replace, each lone surrogate becoming a question mark
func FirstUnencodableSurrogate ¶
First surrogate outside U+DC80 through U+DCFF, the match of the lone surrogate refusal pattern
func GroupThousands ¶
Decimal text of n with comma thousands separators like format(n, ",")
func IsCaseIgnorable ¶
Unicode Case_Ignorable property, marks format and modifier classes plus the word break mid letter set
func IsCased ¶
Unicode Cased property, uppercase lowercase or titlecase letters and the Other_Lowercase and Other_Uppercase sets
func IsDigit ¶
str.isdigit on one code point, decimal digits plus superscripts circled and other Digit typed numbers
func IsIdentifier ¶
str.isidentifier, an XID_Start or underscore followed by XID_Continue code points
func IsPrintable ¶
str.isprintable on one code point, refusing separators other than space and the C categories
func IsSpace ¶
Code points str.isspace accepts, Unicode White_Space plus the ASCII file group record and unit separators
func IsUpper ¶
Python str.isupper, true when no character is lowercase or titlecase and at least one is uppercase
func IsXIDContinue ¶
Unicode XID_Continue, XID_Start plus marks digits connectors and Other_ID_Continue
func IsXIDStart ¶
Unicode XID_Start, letters letter numbers and Other_ID_Start minus pattern characters and NFKC unstable ones
func Slice ¶
Code points of s from start to end with Python subscript clamping and negative indexes from the end
func SplitWhitespace ¶
str.split(None, maxsplit), whitespace runs as separators and the remainder keeping trailing space once maxsplit is spent
func Splitlines ¶
str.splitlines over every Python line boundary, carrying the boundaries when keepends is set
func StrIsDigit ¶
True for a non empty string whose every character is a digit, str.isdigit
func StrictUTF8EncodeError ¶
UnicodeEncodeError of a strict utf-8 encode over the first surrogate run, nil for text holding no surrogate
func StripChars ¶
str.strip(chars) removing any code point of chars from both ends
func SurrogateAt ¶
Whether the three bytes at i are the generalized UTF-8 form of a surrogate code point
func SurrogateEscapeDecode ¶
Python bytes.decode with utf-8 and surrogateescape, each undecodable byte becoming U+DC80 through U+DCFF
func SurrogateEscapeEncode ¶
Python str.encode with utf-8 and surrogateescape, the exact inverse of the surrogateescape decode
func SurrogateRune ¶
Code point of the surrogate whose three byte form starts at i
func TextwrapWrap ¶
func TextwrapWrap(text string, o TextwrapOptions) []string
TextwrapWrap is textwrap.wrap with the given TextWrapper options
func TextwrapWrapNoHyphenBreak ¶
TextwrapWrapNoHyphenBreak is textwrap.wrap with break_on_hyphens False and the other options at their defaults
func Title ¶
str.title, titlecasing a code point after an uncased one and lowercasing it after a cased one
func TranslateNewlines ¶
Text with CRLF and lone CR turned into LF, as Python text mode reads with universal newlines
func UTF8DecodeError ¶
UnicodeDecodeError text of a strict utf-8 decode that stops at pos, with the CPython reason and span
func UTF8MaximalSubpart ¶
Length of the maximal invalid UTF-8 subpart at the start of b
func ValidIndex ¶
Offset of the first byte that is neither UTF-8 nor a three byte surrogate, ok when there is none
Types ¶
type TextwrapOptions ¶
type TextwrapOptions struct {
Width int
InitialIndent string
SubsequentIndent string
ExpandTabs bool
ReplaceWhitespace bool
DropWhitespace bool
BreakLongWords bool
BreakOnHyphens bool
TabSize int
}
TextwrapOptions are the textwrap.TextWrapper keyword arguments
func DefaultTextwrap ¶
func DefaultTextwrap(width int) TextwrapOptions
DefaultTextwrap is TextWrapper(width) with every other argument at its Python default
type UnicodeDecodeError ¶
type UnicodeDecodeError struct{ Msg string }
UnicodeDecodeError raised by a strict codec decode, carrying the CPython message
func (*UnicodeDecodeError) Error ¶
func (e *UnicodeDecodeError) Error() string
func (*UnicodeDecodeError) PyTypeName ¶
func (e *UnicodeDecodeError) PyTypeName() string
Python exception class name the error stands for
type UnicodeEncodeError ¶
type UnicodeEncodeError struct {
// contains filtered or unexported fields
}
UnicodeEncodeError of the utf-8 codec over the surrogate run start to end of a str
func (*UnicodeEncodeError) Error ¶
func (e *UnicodeEncodeError) Error() string
func (*UnicodeEncodeError) PyTypeName ¶
func (e *UnicodeEncodeError) PyTypeName() string
Python exception class name the error stands for