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

# toUtf8String

```ts theme={null}
function toUtf8String(bytes, onError?): string
```

Returns the string represented by the UTF-8 data `bytes`.

When `onError` function is specified, it is called on UTF-8 errors allowing recovery using the
[**Utf8ErrorFunc**](/sdk/content/type-aliases/Utf8ErrorFunc) API. (default: [error](Utf8ErrorFuncs))

## Parameters

| Parameter  | Type                                                       | Description                  |
| :--------- | :--------------------------------------------------------- | :--------------------------- |
| `bytes`    | [`BytesLike`](/sdk/content/type-aliases/BytesLike)         | The UTF-8 data to convert.   |
| `onError`? | [`Utf8ErrorFunc`](/sdk/content/type-aliases/Utf8ErrorFunc) | The error handling function. |

## Returns

`string`

The string.

## Source

[encoding/utf8.ts:348](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/encoding/utf8.ts#L348)
