luastrings

package
v0.0.0-...-e0b5347 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const RuneError = utf8.RuneError
View Source
const (
	UTFMax = 6 // Originally 4 in unicode/utf8

)

Variables

This section is empty.

Functions

func DecodeRuneInString

func DecodeRuneInString(s string) (r rune, size int)

DecodeRuneInString is like DecodeRune but its input is a string. If s is empty it returns (RuneError, 0). Otherwise, if the encoding is invalid, it returns (RuneError, 1). Both are impossible results for correct, non-empty UTF-8.

An encoding is invalid if it is incorrect UTF-8, encodes a rune that is out of range, or is not the shortest possible UTF-8 encoding for the value. No other validation is performed.

func GetDecodeRuneInString

func GetDecodeRuneInString(lax bool) func(string) (rune, int)

GetDecodeRuneInString return a decode function that is strict or lax about the utf8 encoding depending on the value of lax. For details see the UTF-8 support section in the Lua 5.4 manual.

func NormalizeNewLines

func NormalizeNewLines(b []byte) []byte

func Quote

func Quote(s string, quote byte) string

Quote a string so that it is a valid Lua string literal

func StringNormPos

func StringNormPos(s string, p int) int

StringNormPos returns a normalised position in the string i.e. -1 -> len(s)

-2 -> len(s) - 1

etc

func UTF8EncodeInt32

func UTF8EncodeInt32(p []byte, i int32) int

Encode a unicode point with value i into a sequence of bytes, writing into p. p must be big enough (length 6 accomodates all values). Returns the number of bytes written. A non-positive value means an error.

Any non-negative int32 can be encoded, that is why the golang utf8 package cannot be used.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL