# sm.util.clampUtf8String

Clamps a UTF-8 string to a maximum number of characters without splitting multi-byte sequences.

**Kind:** Function

**Environments:** Game, Terrain

## Game

``` { .lua .api-signature }
sm.util.clampUtf8String( string, maxLength )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.util.md#clamputf8string)

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `string` | string | The input string. |
| `maxLength` | integer | The maximum number of UTF-8 characters. |

**Returns:**

| Type | Description |
| --- | --- |
| string | The clamped string. |

## Terrain

``` { .lua .api-signature }
sm.util.clampUtf8String( string, maxLength )
```

[Open the full Terrain reference](../Terrain-Script-Environment/Static-Functions/sm.util.md#clamputf8string)

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `string` | string | The input string. |
| `maxLength` | integer | The maximum number of UTF-8 characters. |

**Returns:**

| Type | Description |
| --- | --- |
| string | The clamped string. |
