Documentation
¶
Overview ¶
Package utf8string provides types and helpers (currently just one String type) designed for making certain uses of unicode strings more efficient.
The String type stores a UTF-8 encoded string as well as a memory-efficient slice of exceptions to the most common encoded code-point size.
Other types may be added at a later date.
Index ¶
- type Cursor
- type String
- func (u *String) RuneLen() int
- func (u *String) SeekByte(boffset int) Cursor
- func (u *String) SeekRune(roffset int) Cursor
- func (u *String) SeekUTF16(u16offset int) Cursor
- func (u *String) SliceByte(i, j int) String
- func (u *String) SliceRune(i, j int) String
- func (u *String) SliceU16(i, j int) String
- func (u *String) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is the main type of the utf8string package, it represents an indexed utf8 string with O(log(m)) slicing by rune offset where m is the number of runes with encodings requiring an uncommon number of runes.
func (*String) RuneLen ¶
RuneLen returns the number of runes in the string, with a result equivalent to len([]rune(u.String())), (but in constant time).
func (*String) SeekRune ¶
SeekRune returns the offset in bytes into the contained string for that rune offset.
func (*String) SeekUTF16 ¶
SeekUTF16 returns a Cursor for the UTF-16 offset (useful in webassembly when interacting with JS strings)
func (*String) SliceByte ¶
SliceByte returns a substring of u on the interval [i, j) (matching the slice expression u.String()[i:j]), except the relevant components of the index are preserved.
func (*String) SliceRune ¶
SliceRune returns a substring of u on the rune-interval [i, j) (matching the slice expression string([]rune(u.String())[i:j])), except the relevant components of the index are preserved.