Tag-Length-Value (TLV) is a method of encoding fields of data within a single string of data or a barcode symbol. Base64 is a method of encoding a string of data, which makes the text that is encoded appear encrypted. Base64 conversion is also used to support the encoding of Unicode characters, such as Arabic text, with systems such as barcode scanners that cannot otherwise support these characters. It is a requirement per KSA Zakat, Tax and Customs Authority (ZATCA) of Saudi Arabia to encode e-invoicing fields in TLV format and then encode that string in Base64 within a QR Code.
The following is a simple overview of this process:
- Obtain the fields of data to encode
- Calculate TLV values before each field of data
- Combine the fields and TLV values into a single string
- Convert the string to Base64
- Encode the result in a QR Code symbol
Below is a TLV Base-64 encoded QR Code invoice example that includes UTF-8 Unicode characters.
A standard scanner will show the base64 string of data that is encoded. The data can be better examined and tested with the IDAutomation Data Decoder Verifier App. TLV values are shown in Hexadecimal before each field. The app also verifies that the TLV fields are encoded correctly. The scan result will decode the base64 string and show the tag (field number) and the length (length of the next field) and the value (the data in the field).
IDAutomation offers an enhanced encoding ability to support TLV with and without Base64 in QR Code for products updated in 2022 or later. The following options are available when the ApplyTilde or ProcessTilde option is enabled.
- Encode TLV into Base64: This allows TLV fields to be encoded in Base64 when the first character is | and the fields are separated by |
Example: |IDAutomation|123456789012345|2022-11-30 06:04:31|92435.33|2692.22
- Encode TLV Only: When the first two characters are ^| TLV values separated by | are encoded.
Example: ^|IDAutomation|123456789012345|2022-11-30 06:04:31|92435.33|2692.22
- Encode Base64 Only. When the first character is “=” all data is encoded in Base64.
Example: =This text is encoded in Base-64
This capability is supported in all IDAutomation QR Code product versions 2022 or later including:
- .NET Barcode Generator
- ASPX Barcode Generator Script
- Access Barcode Generator
- Barcode Generator Subscription Service (SaaS)
- Barcode Label Software Pro
- C++ Header File (Included with the QR Code Font and Encoder)
- Crystal Reports QR Code Generator (Includes implementation example)
- Excel Barcode Generator
- FileMaker QR Code Generator
- Font Encoder App
- Google Sheets | Docs QR Code Generator
- IIS Streaming Barcode Server
- Java Barcode Generator Package
- SSRS Barcode Generator
- Windows Forms Control (WinForms)
- QR Code Font and Encoder Suite (All components except legacy encoders)