# Utf32 encode

`utf32-encode` · version 1.0.0 · Encoding & checksums · free, no key needed

Encode Unicode scalar text as bit-exact UTF-32LE or UTF-32BE base64 bytes with an optional BOM.

**Use when you need to: encode text as UTF-32 · convert text to UTF-32LE · convert text to UTF-32BE.**

## Decide before calling

Read the [versioned contract](/v1/tools/utf32-encode/versions/1.0.0) and the supported scope below. Reuse `utf32-encode@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `utf32-encode@1.0.0` for encode text as UTF-32. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- encode text as UTF-32
- convert text to UTF-32LE
- convert text to UTF-32BE
- add a UTF-32 BOM
- produce base64 UTF-32 bytes
- serialize Unicode scalar values

## Not supported

- encode lone surrogates
- normalize or repair text

## Behavior

- Implements Unicode Standard 16.0, Unicode Encoding Schemes.
- Each Unicode scalar is emitted as exactly four bytes in the selected byte order.
- A requested BOM is emitted before text; text itself is never normalized.
- Surrogates are invalid; noncharacters follow the requested policy.
- Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity.

## Input

- `text` (string, required): max length 1024
- `endian` (one of "le", "be", required)
- `bom` (boolean, required)
- `noncharacters` (one of "allow", "reject", required)

## Output

- `base64` (string, required): max length 5464
- `byte_length` (integer, required): min 0; max 4096
- `endian` (one of "le", "be", required)
- `bom` (boolean, required)
- `standard_version` (constant "Unicode Standard 16.0, Unicode Encoding Schemes", required)

## Limits

- max input bytes: 4096
- max code points: 1024
- max output bytes: 4096

## Example

Request input:

```json
{
  "text": "A",
  "endian": "le",
  "bom": false,
  "noncharacters": "allow"
}
```

Response:

```json
{
  "result": {
    "base64": "QQAAAA==",
    "byte_length": 4,
    "endian": "le",
    "bom": false,
    "standard_version": "Unicode Standard 16.0, Unicode Encoding Schemes"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "utf32-encode",
  "version": "1.0.0",
  "input": {
    "text": "A",
    "endian": "le",
    "bom": false,
    "noncharacters": "allow"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/utf32-encode/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"A","endian":"le","bom":false,"noncharacters":"allow"}'
```

The machine-readable contract is at [/v1/tools/utf32-encode/versions/1.0.0](/v1/tools/utf32-encode/versions/1.0.0).

### CLI

```sh
node cli.mjs run utf32-encode 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Utf32 decode](/tools/utf32-decode): Decode strict base64 UTF-32LE or UTF-32BE bytes after BOM, alignment, scalar, and noncharacter validation.
- [Utf32 BOM inspect](/tools/utf32-bom-inspect): Inspect base64 bytes for UTF-32 alignment and a UTF-32LE or UTF-32BE byte-order mark without guessing.
- [Bech32 encode](/tools/bech32-encode): Encode lowercase HRP and 5-bit data as Bech32 or Bech32m text using that checksum.
- [Iso8859 semantic encode](/tools/iso8859-semantic-encode): Encode logical Unicode text as ISO-8859-6 Arabic, ISO-8859-8 Hebrew, or ISO-8859-11 Thai bytes.
- [Bech32 convert bits](/tools/bech32-convert-bits): Regroup integers between bit widths using BIP 173 rules, rejecting bad leftover padding.
- [Pem envelope format](/tools/pem-envelope-format): Format a label and lowercase hex bytes as a canonical RFC 7468 PEM envelope.
