# encodeStringKey

> **encodeStringKey**(`value`): `Uint8Array`

Defined in: [packages/key-encoding/src/scalars.ts:219](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/key-encoding/src/scalars.ts#L219)

Encode a string as its UTF-8 bytes under [encodeBytesKey](/reference/knotkit/key-encoding/functions/encodebyteskey/), so keys sort by Unicode code point.

Code point order equals JavaScript’s `<` on strings except where a supplementary character (U+10000 and above, held as a surrogate pair) meets a character in U+E000 .. U+FFFF: `<` compares UTF-16 code units and puts the supplementary character first, code point order puts it last.

## Parameters

### value

`string`

## Returns

`Uint8Array`

## Throws

`INVALID_KEY_VALUE` when `value` is not a string or holds an unpaired UTF-16 surrogate, which UTF-8 cannot represent; refusing it keeps every decoded key equal to the string encoded.
