> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stellarium.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Strings

> String functions in sh.stellarium.stdlib.Strings.

```requestscript theme={null}
const strings: sh.stellarium.stdlib.Strings
```

## length

Returns the length of a string.

**of** `string` *required*

The string to get the length of.

**value** `int32`

The number of characters in `of`.

```requestscript theme={null}
request LengthOfString {
  const strings: sh.stellarium.stdlib.Strings

  const msg = "Hello World!"
  const length = strings.length(of: msg)

  if (length.error != null) {
    return -1
  }

  return length.value
}
```

```json Response theme={null}
{ "returnValue": 12 }
```

> [!NOTE]
>
> Length is counted in UTF-16 code units, like JavaScript's `String.length`. Characters outside the Basic Multilingual Plane, such as most emoji, count as 2. `"👋"` has a length of `2`.

If `of` isn't a string, `length` returns `-1` instead of an error.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.