Skip to content
lsl.devlsl.devLSL Dev

llStringLength

function
Function syntax
integer llStringLength(
  1. string str// String to measure.
);
Returns
integer
Energy
10

Returns an integer that is the number of characters in str.

How to use
integer result = llStringLength("");
  • The index of the last character is not equal to the string length.
  • Character indexes start at zero (the index of the first character is zero).
  • llStringLength returns the number of characters - not bytes - in the string.
  • Some functions that accept strings are limited to bytes, not characters.
  • LSL-2 uses UTF-8 strings and Mono uses UTF-16; both support multibyte characters.
  • To get the number of bytes in a string instead, use the example snippet on llStringToBase64 (there is no native LSL function to do this).
Example 1
// assumptions:
// object name: LSLWiki
// script name: _lslwiki
default
{
state_entry()
{
string HowLongAmI = "123";
integer strlen = llStringLength(HowLongAmI);
llOwnerSay( "'" + HowLongAmI + "' has " +(string) strlen + " characters.");
// The owner of object LSLWiki will hear
// LSLWiki: '123' has 3 characters.
}
}
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.

From the Second Life Wiki

Community documentation adapted from LlStringLength, by Linden Research, Inc. and contributing residents.View contributors and history.

Imported wiki revision:

Licensed under CC BY-SA 3.0. Last wiki edit: .Formatting and links have been adapted for this site; API metadata follows the LSL definitions.