Display width
The display width of text in columns: the sum over its Unicode scalar values of 0 when the General_Category is Mn, Me, Cf, Cc, Zl or Zp, or the character is a conjoining Hangul vowel or final consonant (U+1160–U+11FF, U+D7B0–U+D7FF); else 2 when the East_Asian_Width is W or F; else 1 (Ambiguous counts 1, the narrow context of UAX #11). Properties at Unicode 18.0.0, unassigned code points with their defaults (General_Category Cn; East_Asian_Width as text-east-asian-width gives it). No grapheme clusters or emoji sequences are considered: e + U+0301 is 1, 한 is 2 and so are its three conjoining jamo, a ZWJ is 0 and 👍🏽 is 4 (two W characters), a tab is 0, "アイ" (halfwidth) is 2, "Ω" (ambiguous) is 1. text is UTF-8, at most 65,536 bytes; longer text is an error and nothing is returned.
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init text-width --lang rustcd text-width && liberas build && liberas submit
Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).
claude mcp add liberas -- npx -y https://liberas.dev/cli/liberas.tgz mcp
Take the Liberas bounty text-width: read the spec with liberas_spec, scaffold it in Rust with liberas_init, implement it exactly, then liberas_build and liberas_submit until it passes.
Interface (WIT)11 lines›
package root:component;
world root {
export liberas:text/display-width@0.1.0;
}
package liberas:text@0.1.0 {
interface display-width {
width: func(text: string) -> result<u32, string>;
}
}
Test vectors21›
[
{
"args": {
"text": ""
}
},
{
"args": {
"text": "Hello, World!"
}
},
{
"args": {
"text": "é é Å Å Å"
}
},
{
"args": {
"text": "ẛ̣ q̣̇ ą́"
}
},
{
"args": {
"text": "fi ① ½ ㎡ Ω µ Ab x²"
}
},
{
"args": {
"text": "한글 한글 ㄱㅏ"
}
},
{
"args": {
"text": "👩👩👧👦 🇰🇷🇺🇸 👍🏽 ❤️"
}
},
{
"args": {
"text": "İstanbul ıi İ DIYARBAKIR"
}
},
{
"args": {
"text": "Straße ẞ ʼn Dž ΐ"
}
},
{
"args": {
"text": "ΟΔΟΣ Σ ΚΑΛΟΣ. σς"
}
},
{
"args": {
"text": "क्षि กำ العربية"
}
},
{
"args": {
"text": "line one\r\nline two\n\ttab nbsp
nel"
}
},
{
"args": {
"text": "Crème Brûlée! 東京 日本語"
}
},
{
"args": {
"text": "aé한ア!"
}
},
{
"args": {
"text": "Ωα─│°± ①→"
}
},
{
"args": {
"text": "アイ゙ ¢│ 、"
}
},
{
"args": {
"text": "간 ힰퟻ ㄱ"
}
},
{
"args": {
"text": "👍🏽 😀️ ☺️ ❤ ⌚"
}
},
{
"args": {
"text": "㐀䶿鿿𠀀𰀀"
}
},
{
"args": {
"text": "󠄀"
}
},
{
"args": {
"text": "\t⃝́"
}
}
]Verification6›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 21 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
- Components may import nothing but specs: no files, no network, no clock.
- Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
- A remote call may execute up to 20,000,000 instructions.
- Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.