Documentation ¶
Overview ¶
Package lzstring implements the LZ-String algorithm for string compression and decompression. The library features two main sets of functions, Compress and Decompress, which are used to compress and decompress strings, respectively.
Index ¶
- Variables
- func Compress(uncompressed string) ([]uint16, error)
- func CompressToBase64(uncompressed string) (string, error)
- func CompressToEncodedURIComponent(uncompressed string) (string, error)
- func CompressToUTF16(uncompressed string) ([]uint16, error)
- func CompressToUint8Array(uncompressed string) ([]byte, error)
- func Decompress(compressed []uint16) (string, error)
- func DecompressFromBase64(compressed string) (string, error)
- func DecompressFromEncodedURIComponent(compressed string) (string, error)
- func DecompressFromUTF16(compressed []uint16) (string, error)
- func DecompressFromUint8Array(compressed []byte) (string, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Compress ¶
Compress takes an uncompressed string and compresses it into a slice of uint16. It returns an error if the input string is not a valid UTF-8 string. Note: The resulting uint16 slice may contain invalid UTF-16 characters, which is consistent with the original algorithm's behavior.
func CompressToBase64 ¶
CompressToBase64 takes an uncompressed string and compresses it into a Base64 string. It returns an error if the input string is not a valid UTF-8 string.
func CompressToEncodedURIComponent ¶
CompressToEncodedURIComponent takes an uncompressed string and compresses it into a URL-safe string, where special characters are replaced with safe alternatives. It returns an error if the input string is not a valid UTF-8 string.
func CompressToUTF16 ¶
CompressToUTF16 takes an uncompressed string and compresses it into a slice of uint16, where each element represents a UTF-16 encoded character. It returns an error if the input string is not a valid UTF-8 string.
func CompressToUint8Array ¶
CompressToUint8Array takes an uncompressed string and compresses it into a slice of bytes. It returns an error if the input string is not a valid UTF-8 string.
func Decompress ¶
Decompress takes a compressed slice of uint16 main contain invalid UTF-16 characters and decompresses it into a string. It returns an error if the input is not a valid compressed data.
func DecompressFromBase64 ¶
DecompressFromBase64 takes a compressed Base64 string and decompresses it into a string. It returns an error if the input is not a valid compressed data.
func DecompressFromEncodedURIComponent ¶
DecompressFromEncodedURIComponent takes a compressed URL-encoded string and decompresses it into a string. It returns an error if the input is not a valid compressed data.
func DecompressFromUTF16 ¶
DecompressFromUTF16 takes a compressed slice of uint16 UTF-16 characters and decompresses it into a string. It returns an error if the input is not a valid compressed data.
func DecompressFromUint8Array ¶
DecompressFromUint8Array takes a compressed slice of bytes and decompresses it into a string. It returns an error if the input is not a valid compressed data.
Types ¶
This section is empty.