A bar code is a series of vertical lines – called bars – and spaces, both of varying width. Different combinations of bars and spaces represent different characters. A bar code scanner essentially emits light onto the bar code; the light is absorbed by the dark bars and reflected by the space (which is white). The scanner has a photocell detector that receives the reflected light and converts it to an electrical signal. A low electrical signal is passed for the spaces (where light was reflected), and a high electrical signal for the bars (where nothing was reflected). The widths of the bars and spaces determine the durations of the electrical signal. The decoder inside the bar code reader converts the signal into binary. This binary code is then passed on to a computer.
There are many different ways to represent characters in bar code. Some bar codes are numeric only (for example, UPC and EAN); some have fixed length (for example, UPC-A is 12 digits); and some are for numbers and alphabetic characters (for example, Codes 39 and 128). Of the alphanumeric codes, Codes 39 and 128 are the most common (others include Extended Code 39 and Code 93). All 128 ASCII characters can be encoded using Code 128; Code 39, the more often used of the two, can only encode a total of 43 characters.
Sources used in this document:
http://www.barcodehq.com/primer.html#WHAT
http://www.hudsoncontrol.com/products/barcode_intro.htm