Documentation
¶
Overview ¶
Package jsstring preserves JavaScript UTF-16 units at Go string boundaries. Lone surrogate units use WTF-8; ordinary Unicode strings retain their normal UTF-8 encoding.
Index ¶
- func Canonical(text string) string
- func DecodeRuneInString(text string) (r rune, size int)
- func FromUTF8(data []byte) string
- func FromUTF16(units []uint16) string
- func IndexOf(text, search string, from int) int
- func LastIndexOf(text, search string, from int) int
- func Length(text string) int
- func Slice(text string, start int, ends ...int) string
- func Splice(text string, start, end int, insert string) string
- func ToUTF8(text string) []byte
- func ToUTF16(text string) []uint16
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Canonical ¶
Canonical preserves UTF-16 units while giving paired surrogates their ordinary UTF-8 spelling.
func DecodeRuneInString ¶
DecodeRuneInString reads a JavaScript code point from UTF-8/WTF-8. Adjacent encoded surrogate halves combine just as UTF-16 codePointAt does after strings are concatenated.
func FromUTF8 ¶
FromUTF8 decodes operating-system bytes like Buffer.toString("utf8") and napi_create_string_utf8: each maximal ill-formed subpart becomes one replacement character, and a leading BOM is retained.
func IndexOf ¶
IndexOf implements String.indexOf with UTF-16 positions, including searches for a surrogate half inside a pair.
func LastIndexOf ¶
LastIndexOf implements String.lastIndexOf, whose from argument bounds the start of the match and clamps negative positions to zero.
func Slice ¶
Slice applies String.slice's unit offsets, including negative offsets, an omitted end and retained surrogate halves.
func Splice ¶
Splice joins the prefix before start, insert, and the suffix beginning at end, using String.slice's UTF-16 offset rules.
Types ¶
This section is empty.