CODE128 - lindell/JsBarcode GitHub Wiki

About CODE128

CODE128 is one of the more versatile barcodes. It has support for all 128 ASCII characters but does also encode numbers efficiently. It has three modes (A/B/C) but can switch between them at any time. CODE128 is the default barcode that JsBarcode will choose if nothing else is specified.

Supported modes

Auto (recommended)
JsBarcode("#barcode", "Example1234"); //CODE128 (auto) is the default mode
JsBarcode("#barcode", "Example1234", {format: "CODE128"}); //But you can still specify it
Forced modes

If the barcode scanner only support one type of CODE128 you can force that mode.

JsBarcode("#barcode", "EXAMPLE\n1234", {format: "CODE128A"});
JsBarcode("#barcode", "Example1234", {format: "CODE128B"});
JsBarcode("#barcode", "12345678", {format: "CODE128C"});

ean128 option for CODE128

Enable encoding CODE128 as GS1-128/EAN-128.

JsBarcode("#barcode", "12345678", {
  format: "CODE128C",
  ean128: true
});

Non printable characters

CODE128 supports all 128 ASCII characters. You can input them in a few ways.

Here comes examples where characters Newline, Horizontal tab and Carriage return

JsBarcode("#barcode", "\n\t\r");
JsBarcode("#barcode", "\x0A\x09\x0D");
JsBarcode("#barcode", String.fromCharCode(10, 9, 13));

For information about all ASCII character, see ASCIItable.com.