Device + Agent
The functionality of Squirrel’s string object is extended in two ways: the language’s own string library, which adds a series of standalone functions, and the data type’s delegate object, which provides a series of methods called using dot syntax. Both library and delegate provide tools for manipulating strings and the characters they contain.
Strings are technically addressed by reference, but because they are also immutable, it is not possible to write code that can tell that strings behave differently from scalar values.
Device-side Squirrel does not deal correctly with strings longer than 65,535 bytes. No warnings or errors are currently generated, either at compile-time (for literals) or run-time (for constructed strings), but oversize strings behave as if their lengths were reduced modulo 65,536.
Workaround Check the lengths of strings likely to contain 65,535 Ascii characters (fewer if you use unicode) and segment into multiple strings as necessary.
If you attempt to use relative comparison operators, such as
<=>, with strings that contain
NUL characters (ie. bytes of value 0), then Squirrel will ignore any characters beyond the first
NUL. For example:
local a = "r" + "\x00" + "a"; local b = "r" + "\x00" + "c"; server.log(b <=> a);
0 because the two strings’ first characters are the same; the final characters come after
NULs so are ignored.
This is not the case with equality comparison operators (
==) — Squirrel includes any
NULs present in the string in the comparison.
For more guidance on using strings, please see the Squirrel Programming Guide.
The string object has the following member methods:
The string object has the following member functions: