kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

normalizeNumerals misreads Unicode mathematical digits

Open rtibblesbot opened this issue 1 month ago • 1 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: develop

Observed behavior

normalizeNumerals gives the wrong value for Unicode mathematical digits that do not start their run:

  • normalizeNumerals('𝟙') (U+1D7D9, double-struck 1) returns '11'.
  • normalizeNumerals('𝟣') (U+1D7E3, sans-serif 1) returns '21'.
  • Bold digits (U+1D7CE–U+1D7D7) read correctly.

U+1D7CE–U+1D7FF is one unbroken 50-character run of \p{Nd} digits. The function walks back to the start of the run and subtracts, so its comment's "at most 9 steps" does not hold. Every \p{Nd} run is a multiple of 10 long.

User-facing consequences

A learner who pastes such digits into a Numeric TextEntryInteraction in qti_viewer has their answer read as a different number.

Steps to reproduce

  1. In a jest test or browser console, import normalizeNumerals from kolibri-common/utils/numeralNormalization.
  2. Call normalizeNumerals('𝟙').

Acceptance Criteria

  • [ ] normalizeNumerals returns '1' for 𝟙 (U+1D7D9) and 𝟣 (U+1D7E3), and '0'–'9' for every digit in U+1D7CE–U+1D7FF.
  • [ ] numeralNormalization.spec.js covers a digit from the middle of the mathematical run.

AI usage

Claude Code found this while reviewing Studio's vendored copy in learningequality/studio#6282, which fixes the same bug, and drafted this issue.

rtibblesbot avatar Oct 07 '26 00:10 rtibblesbot

Plan: normalizeNumerals reads every \p{Nd} digit as its value 0–9, including digits inside runs longer than 10.

  • [ ] Read digits from runs longer than 10
  • [ ] Self-review the produced code

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Oct 19 '26 02:10 rtibblesbot