How To Render The "÷" Symbol in Code 128 Barcodes: A Quick Solution

If you ever tried generating a barcode in Code 128 format that contains the ÷ symbol, you might have noticed that with Docentric, you can successfully generate a live preview and a valid PDF preview. However, when you scan the barcode, it turns out to be invalid.

Why does this happen, and how can you resolve it?


The Root Cause

The root of this problem lies in the way Code 128 barcodes interpret the ÷ symbol. As described on the Wikipedia page for Code 128, Code 128 uses a series of narrow and wide bars and spaces to encode data, and not all symbols and characters are directly compatible or supported, including the ÷ symbol. Consequently, when scanned, the barcode is invalid.


The solution is very simple and straightforward.

By replacing the ÷ symbol with the ôw character combination, you can effectively work around this encoding issue. Here, ô is interpreted as the FNC4 symbol in Code 128, and w is a stand-in for the ÷ symbol, adapted for Code 128.

Here is a sample expression demonstrating the solution:

replace(SalesInvoiceHeaderFooterTmp/@SalesId, '÷', 'ôw')


This solution ensures that your barcode remains valid and scannable, bypassing the problem presented by the direct use of the ÷ symbol.


In summary, using the replace function to replace unsupported characters with alternative valid characters is a simple yet effective solution that can help you overcome challenges in generating Code 128 barcodes involving special characters.

Next time you’re working with Code 128 barcodes with special characters, check if Code 128 supports the special characters in your barcode, and if not, review alternative characters to work around it.