How to Generate Barcodes (CODE39) in Unicode Symbols with JavaScript

Charmaine Chui
Webtips
Published in
3 min readJan 31, 2022

--

▌ ▌█▌█▌▌█▌█▌ ▌▌▌▌█▌ ▌█▌▌▌ ▌█▌█▌▌⇾ Encodes ❛39❜

Barcodes have long been used as means of item identifications as early as in the 1970s. In present day it has been widely implemented as a universal standard across several Global Supply Chain logistics processes and procedures.

CODE39 Barcodes

1 of the earliest forms of Barcodes is CODE39 — with a charset of 44. These characters encompasses the following alphanumerical values:

Alpha: A-Z (uppercase only. any lowercase characters shall be auto-transformed to uppercase.)

Numerical: 0–9

Other Symbols: + - * / % $ , _ (any single space ' ' is auto-replaced by the underscore '_' character)

Each character display has the following set of rules to follow:

Illustration by Author | Each character in a CODE39 Barcode has 5 Bars, 4 Spaces. In both scenarios, there are 2 specific lengths which follows the ratio of 2:5 as illustrated above.

In addition, each barcode is always prefixed and suffixed with an asterisk *. E.g. when 2 characters ❛39❜ are actually encoded as CODE39, the displayed barcode renders ❛*39*❜ instead.

Note: Barcode scanners will still read this as ❛39❜ as intended.

While there are open-sourced wrapper Barcode JS libraries JsBarcode, in order to derive the actual mapping for each of the 44 unique characters, variables…

--

--

Charmaine Chui
Webtips

👩‍💻 Data Analyst. Web & Software Developer. Technical Writer✍ | Trying to make the 🌐 better with baby steps👣 [ 📍SG ] LinkedIn@https://tinyurl.com/45kf4pc3