Unicode-correct username canonicalisation (NFKC, casefold, mixed-script), terminal width, cluster-safe truncation and slugs
Exact prompt
# Task: make the text helpers Unicode-correct Rewrite the four functions in `textnorm.py` (Python stdlib only, `unicodedata` is fine) to these rules: **canonical_username(s)** - used to detect duplicate/impersonating accounts. 1. Remove zero-width/format characters U+200B, U+200C, U+200D, U+2060, U+FEFF and U+00AD (soft hyphen); apply NFKC; casefold (Python `str.casefold()`; note it maps a Greek final sigma ς to σ, so `"Δημήτρης"` -> `"δημήτρησ"`); strip surrounding whitespace. 2. The result must be 3-32 characters, contain only letters (any script, category L*), digits (Nd), `.`, `_`, `-`, and must not mix scripts: all letters must come from one script among Latin, Greek, Cyrillic (judge by `unicodedata.name` starting with `LATIN`, `GREEK`, `CYRILLIC`; letters from any other script are allowed only if all letters are from that same other script, judged by the first word of the name). Otherwise raise `ValueError`. Examples: `" John_Doe "` -> `"john_doe"`; `"STRASSE"` and `"straße"` both -> `"strasse"`; `"pаypal"` (Cyrillic а) -> ValueError. **display_width(s)** - terminal columns: characters with East Asian Width `W` or `F` count 2; combining marks (categories Mn, Me), format chars (Cf) and the zero-width chars above count 0; control characters (Cc) count 0; everything else 1 (so East Asian Width `A`/`N`/`Na`/`H` count 1: `…` is 1, `❤` is 1, each regional-indicator letter is 1 so a flag pair is 2, and U+FE0F is 0 as a combining mark). **truncate(s, width, ellipsis="…")** - if `display_width(s) <= width` return `s` unchanged. Otherwise return the longest prefix such that display_width(prefix) + display_width(ellipsis) <= `width`, never splitting a base character from its following combining marks/ZWJ/variation selectors (U+FE00-FE0F), never splitting a regional-indicator pair (flag) and never leaving a dangling ZWJ (U+200D) at the end of the prefix. Then append ellipsis. If even the ellipsis doesn't fit, return "". **slugify(s)** - NFKD, drop combining marks, map `ß`->`ss`, `æ`->`ae`, `œ`->`oe`, `ø`->`o`, `ł`->`l`, `đ`->`d`, `þ`->`th` (and their uppercase forms), lowercase, then every run of characters other than `a-z0-9` becomes a single `-`; strip leading/trailing `-`. If longer than 60 characters, cut to 60 and then, if the cut fell inside a word (the 60th and 61st characters are both letters/digits), back off to the last `-` within the 60 (when there is one); finally strip trailing `-`. Examples: 20 x "word " -> 12 x "word" joined by `-`; `"abc " + 70 x "y"` -> `"abc"`; 70 x "x" -> 60 x "x". Empty result -> `"n-a"`. No network.
Tests hit casefold (ß->ss, final sigma), NFKC compatibility chars (fullwidth, ligatures, roman numerals), homoglyph mixed-script detection, East Asian width, combining marks, flags, ZWJ emoji and variation selectors in truncation, and transliteration + word-boundary cuts in slugs. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).
Success criteria: 1. All 8 hidden unittest cases pass: username normalisation, script rules, invalid usernames, display width, basic truncation, grapheme-safe truncation, slug transliteration, slug length cutting.
Best model for this task so far: Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) (success, $0.01, 1m).
All runs (4)
100% pass rate across 4 eligible runs: 4 pass, 0 partial, 0 fail. Partial and failed runs are listed below with everything else.ⓘ
| Model | Cost | Time | Step-insⓘ | Autonomy | Outcome | Trustⓘ | Date | Compare |
|---|---|---|---|---|---|---|---|---|
| OGPT-6.1 Soldefault · thinking on | $0.05 | 1m | 0 | Fully autonomous | pass | Trust 80% | 2026-10-22 | |
| AClaude Haiku 5.5default · thinking on | $0.01 | 1m | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 | |
| AClaude Opus 5.5default · thinking on | $0.24 | 58s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 | |
| AClaude Sonnet 5.5default · thinking on | $0.09 | 33s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 |
Embed this result
A live badge for this use case. It links back here and updates as new runs are published.
Get new runs and ranking changes weekly
Which models got better or cheaper on real tasks like this one.