Skip to main content

string

Availability

Device + Agent

Description

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.

Known Issue

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.

Referencing

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.

Further Information

For more guidance on using strings, please see the Squirrel Programming Guide.

Member Entities

The string object has the following member methods:

The string object has the following member functions:

  • format()Formats and returns a string for display
  • lstrip()Removes any whitespace from the left of a string
  • rstrip()Removes any whitespace from the right of a string
  • split()Divides the passed string into an array of sub-strings
  • strip()Removes any whitespace from the both ends of a string