Skip to content

Mixed digit systems in Arabic text

ar-digits-mixedminor
On this page

Why it matters

  • Readers notice numbers changing shape from one paragraph to the next, so the page looks careless, especially in prices, sizes and dates.
  • Search, on the page and in search engines, treats «١٥» and «15» as different text, so someone looking for a price or an order number in one system may not find it in the other.
  • Persian digits (۴ ۵ ۶) differ in shape from Eastern Arabic ones (٤ ٥ ٦); they usually show up when text is typed on a Persian keyboard or copied from a Persian source.

Example

Wrong
<p>علبة تمر مجدول وزنها 500 غرام، فيها نحو 20 حبة كبيرة.</p>
<p>السعر ٤٫٥٠٠ ريال عماني، والشحن مجاني للطلبات فوق ١٥ ريالاً.</p>
Right
<p>علبة تمر فرض وزنها 500 غرام، فيها نحو 20 حبة، بسعر 4.500 ريال عماني شامل ضريبة القيمة المضافة.</p>

How to fix

  • Choose one digit system for the whole site, Western (0-9) or Eastern Arabic (٠-٩), and keep to it in text, prices and tables.
  • If some numbers come from the database or a plugin, format them the same way in the template, such as toLocaleString('ar-SA') or toLocaleString('ar-SA-u-nu-latn') in JavaScript, depending on the system you chose.
  • Replace Persian digits with Arabic ones: ۴ → ٤, ۵ → ٥, ۶ → ٦, or with Western ones.

How we detect

  1. We read the visible text in the page's HTML as the server sends it, on pages where most letters are Arabic, leaving out code tags such as <code>. Pages that declare another language written in Arabic script, such as Persian (fa) or Urdu (ur), are left out: those digits are theirs.
  2. We collect the numbers that stand on their own, with their separators and decimal marks, such as «٤٫٥» and «1,500».
  3. We leave out numbers next to Latin words, such as «iPhone 15» and «Windows 11», international phone numbers that start with +, and the year after ©, since those are usually written in Western digits.
  4. The rule fails when the page has both Western and Eastern Arabic digits, and points at the first number of the system used less. It also fails when there are Persian digits.