# OCTET_LENGTH

> OCTET_LENGTH function in StackQL: the number of bytes in the UTF-8 encoding of a string.

Source: https://stackql.io/language-spec/functions/string/octet_length

Returns the number of bytes in the encoding of a string, where [`LENGTH`](/language-spec/functions/string/length) counts characters.

See also:  
[[` SELECT `]](/language-spec/select) [[` LENGTH `]](/language-spec/functions/string/length)

* * * 

## Syntax

```sql
SELECT OCTET_LENGTH(string) FROM <multipartIdentifier>;
```

## Arguments

__*string*__  
A string or BLOB.  A number is measured in its text form.

## Return Value(s)
Returns an integer.  The result is `NULL` if *string* is `NULL`.

* * *

## Examples

### Characters and bytes

The accented character takes two bytes in UTF-8:

```sql
SELECT LENGTH('héllo') AS chars, OCTET_LENGTH('héllo') AS bytes;
```

```
|-------|-------|
| bytes | chars |
|-------|-------|
| 6     | 5     |
|-------|-------|
```

For more information, see [https://www.sqlite.org/lang_corefunc.html#octet_length](https://www.sqlite.org/lang_corefunc.html#octet_length)
