![]() # Encode: Convert the digits into an interleaved string of bits, with a Strings are used to avoid problems with insignificant zeros, and allowįor iterating over the bits in a byte. The input string must notĬontain an odd number of digits. ![]() '''This function converts its input, a string of decimal digits, into aīarcode, using the interleaved 2 of 5 format. The new code includes many of the suggestions made below. Update: A new version of this code has been posted here. It's a simple format, and there's a Wikipedia article that covers it well. The barcode is in the Interleaved 2 of 5 Format. It's useful, so I could make a little gist out of it.It's complex enough that a new programmer would make a mess of it.It's simple enough to do in one function, so it can be reviewed easily.It's something I recently needed, so not entirely contrived.I was asked to provide some example code for a job interview and didn't have anything to offer, so wrote the following function.Ī barcode generator may seem a bit basic, but there's some logic behind the choice:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |