Skip to content
Tier

Bidi

Free · MIT

Text from a model or a tool, safe to show: each bidi control character (U+202A to U+202E, U+2066 to U+2069) is replaced by a visible mark naming it, such as [U+202E].

Markdown
Version 5.2.0· other versions

This page is for 5.2.0, the current release. An earlier release’s page is the Markdown that release published, so the docs match the version you have installed (candor-lock.json records it).

Not in the docs of 1.3.0, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0, 2.5.1, 2.6.0, 2.6.1, 2.6.2, 2.7.0, 2.8.0, 2.9.0, 2.10.0, 3.0.0, 4.0.0, 4.0.1 and 4.0.2: the page came later, or had another name then.

Docs pages weren’t kept for 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.2.0 and 1.2.1: they are kept from 1.3.0 on, and before that only llms.txt was published.

Preview

It's types and helpers, listed below.

Install

With the Candor CLI
Open the starter in StackBlitz

Opens the free starter app in StackBlitz, in your browser, on stackblitz.com. Bidi isn’t added for you: run npx candor-ui add bidi in its terminal. The starter’s agent needs an Anthropic API key to chat; without one it shows the components only.

First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/bidi

Brings in: tokens

Functions

neutralizeBidi(text: string | undefined)
escapeBidiJson(json: string)

JSON text with each bidi control written as its JSON escape, U+202E as the six characters \u202E, for a field where a person edits JSON a model or a tool wrote (a tool call's input before allowing it). The escape is visible and reorders nothing, and it parses back to the same character, so the input that's sent is still exactly the one proposed. In JSON text a control can only stand inside a string, where the escape means the same.

hasBidiControls(text: string)

Whether text holds a bidi control character that neutralizeBidi would mark.