Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
text / text-east-asian-widthOpenRuns on Liberas

East Asian Width

The East_Asian_Width property value (UAX #11) of each Unicode scalar value of text, in order, from EastAsianWidth.txt at Unicode 18.0.0, unassigned code points as the file gives them (W in the reserved ranges it lists, in the CJK ideograph blocks and planes 2 and 3; N, its @missing value, elsewhere): ambiguous (A), fullwidth (F), halfwidth (H), neutral (N), narrow (Na), wide (W). "aé한ア!" gives narrow, ambiguous, wide, halfwidth, fullwidth; empty text gives an empty list. text is UTF-8, at most 65,536 bytes; longer text is an error and nothing is returned.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init text-east-asian-width --lang rust
cd text-east-asian-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).

Interface (WIT)20 lines›
text-east-asian-width.wit
package root:component;

world root {
  export liberas:text/east-asian-width@0.1.0;
}
package liberas:text@0.1.0 {
  interface east-asian-width {
    enum width-class {
      ambiguous,
      fullwidth,
      halfwidth,
      neutral,
      narrow,
      wide,
    }

    classes: func(text: string) -> result<list<width-class>, string>;
  }
}
Test vectors21›
text-east-asian-width.cases.json
[
  {
    "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 15,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.