Documentation
¶
Overview ¶
Package shortstrings operates on packed canonical WTF-8 strings.
Index ¶
- Constants
- func Bytes(data uint64) [MaxBytes]byte
- func CodePointAt(data uint64, i int) (r rune)
- func Compare(a uint64, aN int, b uint64, bN int) int
- func Concat(a uint64, aN int, b uint64, bN int) (uint64, int, bool)
- func Index(data uint64, n int, sub uint64, subN int, from int) int
- func IsASCII(data uint64) bool
- func IsWellFormed(data uint64) bool
- func LastIndex(data uint64, n int, sub uint64, subN int, from int) int
- func Len(data uint64, n int) int
- func Pack(s wtf8.String) uint64
- func ParseDecimal(data uint64, n int) (uint32, bool)
- func Repeat(data uint64, n, count int) (uint64, int, bool)
- func Slice(data uint64, start, end int) (uint64, int)
- func String(data uint64, n int) wtf8.String
- func ToLowerASCII(data uint64) uint64
- func ToUpperASCII(data uint64) uint64
- func ToWellFormed(data uint64) uint64
- func TrimASCII(data uint64, n int, start, end bool) (uint64, int)
- func UnitAt(data uint64, i int) (u uint16)
- type Builder
Constants ¶
const MaxBytes = 8
MaxBytes is the maximum byte length of a packed string.
Variables ¶
This section is empty.
Functions ¶
func CodePointAt ¶
CodePointAt returns the code point starting at UTF-16 index i. i must be in range.
func Compare ¶
Compare orders the packed strings by UTF-16 code units and returns -1, 0, or 1. aN and bN are their byte lengths.
func Concat ¶
Concat returns the packed concatenation and its byte length, or false if it does not fit. aN and bN are the operands' byte lengths.
func Index ¶
Index returns the first UTF-16 index of sub at or after from, or -1. n and subN are byte lengths, and from must be nonnegative.
func IsWellFormed ¶
IsWellFormed reports whether the packed string contains no lone surrogates.
func LastIndex ¶
LastIndex returns the last UTF-16 index of sub at or before from, or -1. n and subN are byte lengths, and from must be nonnegative.
func ParseDecimal ¶
ParseDecimal parses a nonempty sequence of ASCII decimal digits, or returns false. n is the packed string's byte length.
func Repeat ¶
Repeat returns count copies of the packed string and their byte length, or false if they do not fit. n is the string's byte length, and count must be nonnegative.
func Slice ¶
Slice returns the packed substring and its byte length. start and end must be ordered UTF-16 indices within the string.
func ToLowerASCII ¶
ToLowerASCII converts data to lowercase. data must be a packed ASCII string.
func ToUpperASCII ¶
ToUpperASCII converts data to uppercase. data must be a packed ASCII string.
func ToWellFormed ¶
ToWellFormed replaces lone surrogates with U+FFFD in the packed string, preserving its byte length.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds a canonical WTF-8 string, packed while it fits. Its zero value is ready to use.
func (*Builder) Packed ¶
Packed returns the built string in packed form and its byte length, and reports whether it fits.