Skip to content

Instantly share code, notes, and snippets.

View carlsmith's full-sized avatar

Carl Smith carlsmith

  • Cambridgeshire, UK
View GitHub Profile
@carlsmith
carlsmith / barcode.py
Last active March 27, 2018 11:15
Interleaved 2 of 5, SVG Barcode Generator
def render(digits):
'''This function converts its input, a string of decimal digits, into a
barcode, using the interleaved 2 of 5 format. The input string must not
contain an odd number of digits. The output is an SVG string.
Wikipedia [ITF Format]: http://en.wikipedia.org/wiki/Interleaved_2_of_5
'''
top = '<svg height="58" width="{0}" style="background:white">'