Skip to main content
QR-03ErrorZATCA Security Features Implementation Standardimplemented

TLV Declared Byte Length Within Buffer Bounds

Each TLV length byte must equal the exact UTF-8 byte length (not character length) and never exceed remaining bytes.

Scope
TLV Framing
Applicable Invoice Types
Standard (B2B), Simplified (B2C), Credit Note, Debit Note
Catalog Version
v1.0.0 (2026-11-23)

Typical Reason for Failure

Arabic seller names use string .length (char count) instead of UTF-8 byte count, causing buffer misalignment.

Invalid Synthetic Example

Before (Fails)xml
len('شركة') = 4 (WRONG — Arabic UTF-8 is 8 bytes)

Corrected Synthetic Example

After (Fixed)xml
len('شركة'.encode('utf-8')) = 8 (CORRECT)

Explanation of the Fix

Compute TLV length using UTF-8 byte length: Buffer.byteLength(str, 'utf8').

Official Source Reference

ZATCA Electronic Invoice XML Implementation Standard (Phase 2)

Open official specification

Related Rules

Test your invoice against QR-03 now

Browser quick check; raw XML is never stored.

Open Validator