If you have ever built an e-invoicing app for Saudi Arabia (KSA), you know ZATCA Phase-1 (Fatoora) requires every simplified tax invoice to carry a Base64-encoded TLV (Tag-Length-Value) QR code with 5 fields:
Tag 1: Seller Name
Tag 2: Seller VAT Registration Number (15 digits)
Tag 3: Invoice Timestamp (ISO 8601)
Tag 4: Invoice Grand Total (including VAT)
Tag 5: VAT Total Amount
The #1 Bug That Breaks Arabic Seller Names
Many quick JS snippets use string.length as the TLV Length byte:
// BROKEN FOR ARABIC TEXT: "شركة" has length 4, but is 8 UTF-8 bytes! const badLength = sellerName . length ;
Enter fullscreen mode
Exit fullscreen mode
ZATCA's Fatoora QR scanner validates exact UTF-8 byte lengths , not UTF-16 code units.…