Return the numeric byte codes of a Lua 5.4 string. Supports negative indices and returns one integer per byte in the range.
Reference
String Methods
Methods for string manipulation.
- string.byte
- string.char
string.char in Lua 5.4 takes zero or more integers and returns a string whose bytes are those integer codes. Inverse of string.byte for raw byte sequences.
- string.dump
`string.dump` serializes a Lua function to a binary chunk string that `load()` can rebuild for fast startup, bytecode caching, and shipping precompiled code.
- string.find
string.find searches a Lua string for a pattern match, returning start and end positions. Supports plain literal search to bypass pattern syntax.
- string.format()
string.format() in Lua 5.4 substitutes printf-style %-directives into a string — covers flags, width, precision, specifiers, examples, and pitfalls.
- string.gmatch
string.gmatch returns an iterator that yields every non-overlapping match of a Lua pattern, in order, with captures unpacked for for-in loops.
- string.gsub
string.gsub substitutes pattern matches in Lua strings, returns transformed string and count. Supports string, table, and function replacements.
- string.len
string.len returns the byte length of a Lua 5.4 string. Equivalent to the # operator, it counts embedded NUL bytes and is the canonical way to size a string.
- string.lower
string.lower returns a copy of a string with all ASCII uppercase letters replaced by their lowercase equivalents. Locale-driven; not UTF-8 aware.
- string.match
string.match returns the captures from the first match of a Lua pattern in a string, or the whole match when no captures are defined.
- string.pack
Pack Lua values into a binary string with a format string. Lua 5.4 string.pack reference: every option, alignment rules, and worked examples.
- string.packsize
string.packsize returns the byte length that string.pack would produce for a given format string, without packing any values or allocating a buffer.
- string.rep
string.rep returns a string made of n copies of s, optionally joined by sep, or an empty string when n is not positive.
- string.reverse
Return a copy of a string with its bytes in reverse order. Covers palindrome checks, UTF-8 caveats, and method syntax.
- string.sub
string.sub returns a substring of a Lua 5.4 string by 1-based inclusive byte indices, with negative indices counting back from the end.
- string.unpack
string.unpack reads a binary string produced by string.pack and decodes it into Lua values, with optional start position and a trailing offset for streaming.
- string.upper
string.upper returns a copy of a string with all ASCII lowercase letters replaced by their uppercase equivalents. Locale-driven; not UTF-8 aware.