Using functions to format bar code data

There are many powerful and flexible function to format values; text, number, date, etc.

Leading zeros

TIP: If we use leading zeros, to produce fixed length data, any resulting bar codes will all be the same length.

This code format values in v with up to 6 leading zeros and no decimal places;

char s[80];

int v = 12;

    sprintf(s, "%0*d", 6, v);

    // Now s is "000012"

Dates

Dates are typically formatted in most significant element first; Year (YY or YYYY), Month (MM), Day (DD).

If the date is 07 April 2001, the result is 20010407 (or 010407).

Use this method to format a date, then the result is a numeric and a bar code type can be used to produces the most efficient bar code (Interleaved 2 of 5, Code 128, UCC/EAN-128).

 

 


Copyright 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.