> ## 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.

# toUtf8Bytes

> **注意**: 此页面尚未翻译成中文。以下内容为英文原版。

```ts theme={null}
function toUtf8Bytes(str, form?): Uint8Array
```

Returns the UTF-8 byte representation of `str`.

If `form` is specified, the string is normalized.

## Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `str` | `string` | The string to convert. |
| `form`? | [`UnicodeNormalizationForm`](/cn/sdk/content/type-aliases/UnicodeNormalizationForm) | The normalization form to use. |

## Returns

`Uint8Array`

The UTF-8 byte representation.

## Throws

If the UTF-8 conversion fails.

## Source

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


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