GTIN Code 7640151240103

Primary Keys (8) – Not the variants you are looking for

GTIN Code 7640151240103

The key assumption of any database key is that it uniquely identifies an item. As observed in previous entries, GTIN fulfils that role, most of the time. We recently bought some hair accessories at Migros and the ticket showed three times the same item even though we bought three different things. Upon checking, I realised that all three products share the same GTIN: 7640151240103.
Migros shopping ticket
As all three items share the same code, they also share the same price and the same receipt label. What is interesting is that this is not a case of product variants, these are different products which share the same code.

Migros has a pretty neat mobile app which lets you visualise your shopping tickets. What is interesting is that the product name does not match, the packaging says Fashion Girl, and the receipt Hair fashion standard. There are no identifiers on the packaging nor any information (country or origin, recycling codes), which is pretty unusual for Migros products. One of the product has some bad english indications

It can be used for arranging different hairstyle from the well populan pony tail to the latest fad.

All the information is on a stick-on label with the Migros brand, the barcodes, an indication that these are not toys. Each product has a different SKU: HF 231301, HF 231323 and HF 231410.

This code has the Swiss prefix (76) and is assigned to the company Herba-Imodac AG. But I highly doubt this product is produced in Switzerland, most probably these were built somewhere in Asia, and the labels added by the importer, who did not bother giving them different GTIN even though they have different SKUs.

Flattr this!


Structured Data in Barcodes


Most of the bar codes we see around us are just a sequence of untyped bytes, the reader might infer their meaning based on the encoding (carrier), or by looking at the bytes – if the content starts with http, it probably is a url.

One example of structured bar code is GS1’s expanded Databar. The code is segmented in various fields, whose type is identified by a number. If you look at the bar code in the image, it contains the following fields:

Type Value Note
02 04049500673266 GTIN of the item in the package
17 200630 Expiration data, 30th of June 2020, not 2006.
37 20 Count of Trade Items. The box actually contains 100 pieces.
10 599692006 Batch Number.

What is interesting is that this product has a PZN, the german medical product identifier, with number 06453501, this number could have been encoded in the Databar, with application/type code 710.

Flattr this!

Icon of the Barcode Kingdom Game

Barcode Kingdom

Icon of the Barcode Kingdom Game

Regular readers of this blog would probably have noticed that I’m quite interested into barcodes and the underlying standards. So when I say the gamed called Barcode Kingdom, I was curious. The game itself is a pretty standard simple RPG like game, you control a group of heroes that can be sent to various places, usually to beat up monsters – but letters are to be delivered once in a while – the heroes can be equipped with special weapons and armour, get experience, etc.

Bardcode Kingdom
Publisher: Magic Cube
Operating System: iOS

Tip: if you are difficult to clear the missions, upgrade the items

The only twist is that characters and equipment is acquired using barcodes. Some of them are common, other are rare, the barcode determines this. Now I don’t think this is related to the frequency of the underlying product code, more probably a hash. I order to scan a barcode and get some new stuff, you need some action points, which are basically time dependant.

The game has the typical toony look that is so common on mobile games. While the game is somewhat fun, it feels a bit simplistic and non-intuitive for a 2014 game, it hung multiple times and the english can at best be describe as approximative. The game is not free, it still has the usual in game purchases and many parts of the game are made artificially slower so that people can pay to make it go at a normal speed.

All in all the usage of barcodes feels more like a gimmick than something that was though out properly, in particular the monetisation. There are thousands of pay to un-slow games out there, so adding barcode scanning to this model is not going to rock the boat. Having a fun app that incentivises people to scan barcodes is a powerful way of getting usage and distribution information, so I think making the game free, letting people scan as many codes as they want, and monetising this information would have been more interesting and more fun.

Flattr this!

Wenger Case 22 Label with two GTINs

Primary Keys (5) – Relabelling

Wenger Case 22 Label with two GTINs

When I was a kid, it was a common sight to see people in the supermarket with machines applying price labels to stuff. Nowadays this is something really rare, and only happens when food products are about to run out and are discounted. Still, sometimes, you see a product that has been re-labelled.

Sometimes the new label contains the same barcode, but additional information that is not present on the original packing, this is often the case in pharmacies in Switzerland. Another reason can be that the labels are incorrect, or incomplete, the official price has changed or some other legal changes. And sometimes, it is really hard to know what went on.

I needed a new sleeve for my swiss army knife, so I bought a new one at transa. The sleeve comes in a plastic wrapping, with a perfectly valid barcode, 07611640194054 which is assigned to:

Wenger S.A. Fabrique de Couteaux
Route de Bâle 63
2800 Delémont

Still another label was added with a restricted use code: 2000003332137. The label also contains some additional information: size, colour, weight and another number, 078577-006001 which is not encoded in the barcode. Why change the barcode? One possible reason is that there are variations of the product sharing the same manufacturer provided code and they wish to distinguish them in their system. Another possible reason is that the product originally did not bear a barcode, and the store assigned it a restricted use one so that their system could work, and the product got a manufacturer provided number later. Compatibility…

Flattr this!

Les codes de la poste…

Code DataMatrix du courrier de Cablecom

Si le courrier papier est devenu une sorte de dinosaure, il s’adapte néanmoins et de nombreuses lettres en suisse portent un petit code carré à proximité de l’adresse. Clairement ce code renferme des données liées à l’acheminement du courrier, mais lesquelles ? Cablecom ayant eu l’obligeance de m’envoyer un courrier récemment, c’est une bonne occasion de regarder de quoi il retourne.

Première étape, décoder le code, n’importe quelle application pour téléphone mobile qui comprend le format permet d’extraire les données. Ici on obtient la séquence de chiffres 756803150192692000000000000000004200, ce qui n’est que marginalement plus clair. Heureusement la poste met à disposition la documentation des codes numériques qu’elle utilise, le fichier Barcodes and Data Matrix codes Manual en particulier contient les informations qui nous intéressent : le chapitre Generating data matrix codes décrit le format de données utilisé.

Les trois premiers chiffres contiennent le code ISO de pays numérique, le code pour la Suisse est 756. Les deux chiffres suivants contiennent le code de produit, 80 signifie PostMail le produit de la Poste. Le deux chiffres suivants contiennent le format de code, 31 est un code au format PP Easy avec 36 chiffres, 20 est un code Letter ID sur 36 chiffres, et 21 est un code sur 44 chiffres.

Les huit chiffres suivants, 50192692 contiennent le numéro de client auprès de la poste ESR. Il semblerait qu’il s’agisse d’un numéro à 9 chiffres, mais le dernier sert de contrôle, donc il est omis dans les codes DataMatrix. Les six chiffres suivants sont toujours 0000000 pour les codes PP Easy, dans d’autres formats, il sert à identifier le lot de facturation. Le chiffre suivant est réservé et est toujours 0, les huit chiffres suivants indiquent l’adresse pour le retour de courrier, 0000000 est normal quand le code de contrôle des retours (voir ci-bas) est nul.

Les trois chiffres suivants 420 indiquent le type de produit utilisé, une lettre au courrier A porte le code 001, une lettre au courrier B le code 002, etc. Le code 420 n’est pas défini dans le manuel, mais il semblerait que la Poste a toute une ribambelle de produits, par exemple 311 est pour les références publicitaires de produits. Enfin le dernier chiffre 0 contient les instructions en cas de non acheminement, 0 signifie retour au client sans instructions particulière, c’est la valeur par défaut.

En résumé, ce code ne contient pas grand chose comme information, un numéro de client, le type d’affranchissement, aucune information concernant le destinataire, il s’agit ici juste d’une timbre informatique. Ce que je trouve plus inquiétant, c’est qu’ils n’y a pas le moindre mécanisme de sécurité. N’importe qui peut produire un code valide et utiliser le numéro de client d’un tiers. Une forme de signature cryptographique dans ces codes serait une bonne idée…

Flattr this!

EAN-8 Code – 49641509

Box barcodes

ITF-14 Code – 80000049641505

While the codes on consumer goods around us all use the same UPC/EAN barcodes, there are different formats, different carriers. One you might encounter is the ITF-14 system, which is easily recognisable by its thick black border, called the bearer bar, it is used to label shipping cartons and other boxes that are used to distribute good to the retail shops and or not always recognised by cashiers.

While the graphical representation is different from EAN codes, the information that is encoded within them is compatible: you can know what item is within a box by analysing the code. As the name ITF-14 suggests, the barcode carries a 14 digit number. Remove the leading digit, recompute the check-digit and depending on the number of initial zeroes, you get an EAN-13, a UPC code or an EAN-8.

EAN-8 Code – 49641509

Here the code is 80000049641505, strip the leading 8, and the remaining zeroes and you get 49641505, remove the check digit, we get 4964150 recompute the check digit: (0 × 3) + (5 × 1) + (1 × 3) + (4 × 1) + (6 × 3) + (9 × 1) + (4 × 3) = 51, subtract the last digit from 10 and you get the check-digit: 9. So the code of the items within that box is 49641509.

The value of the first digit of the ITF-14 is not very strictly defined, if it is zero, then the box is considered a single item, maybe because its content is heterogenous (in my limited experience this is pretty rare), 9 should never be present, as this would indicate bulk a good in bulk quantity, not typically what you have in a box. The other numbers just mean some level of packaging, the only recommandation is that higher levels of packaging (more stuff in it), mean a higher number.

Flattr this!

Primary Keys (2)


Incompatible technical standards are one way of getting multiple primary keys, the other is to have organisations that cannot accept keys provided by other organisations. National administrations are particularly good at this, as acknowledging any other national organisation would be akin to admit that there are multiple countries on this planet.

The book Le musée du Silence has two ISBN codes: one for Canada, and one for the rest of the universe. The one used in Québec is 2-7609-2463-7 (978-2-7609-2463-5), and the one used elsewhere is 978-2-7427-5491-5. Notice that there is no common code between the two systems, we have true incompatibility.

It is interesting to see that this book published in 2005, two years before ISBN-13 became mandatory already uses the new system for Europe, but not for America.

Flattr this!

Primary keys…

One UPC, one EAN and one ISBN-10

The idea of primary key is older than computer science itself: libraries have had indexes for ages, and defining a canonical numbering system for referencing things is pretty natural, this is why we have the alphabetical order, or musical notes can be referenced by position in the alphabetical order. Of course this idea works better when there is a single system used, or at least once system was without ambiguity the primary one.

One such key system was ISBN, which assigned a unique, 10 character code to each book. In parallel the UPC system assigned a 12 digit code to things you could buy in a grocery store, this system was US-only, but got extended to work worldwide by making it longer (13 digits). The extended system was called EAN in Europe, JAN in Japan, even though it is the same system.

In parallel, work was done to unify the EAN and ISBN system, and thus was born ISBN-13, which maps all ISBN codes into the EAN space, making it a single, unified system. This means a single barcode system that works both in book shops and grocery stores. This made it easier to sell books in supermarkets and sweets in book-shops.

While this worked out in Europe, it did not in the US, which is still stuck with the 12 digit UPC code. Officially the US should have migrated, but like with other foreign technologies, inertia won, this means foreign products need to be re-labelled when sold in the US and also that books, even when they use ISBN-13 barcodes, cannot be handled by regular barcode scanning systems (the scanner themselves are probably OK, the rest of the system is the problem).

So you end up with the weirdness presented in the image: a book with three identifiers: an ISBN-10 (0-8048-1905-X), an ISBN-13 (978-0-8048-1905-3) and an UPC (6-76251-81905-2). There are also three barcodes, one for the UPC, one for the ISBN-13, and one for the price. As you can convert a UPC into an EAN just by adding a zero in front, this book has two EAN codes: 0-676251-819052 and 9-780804-819053.

The interesting thing is that the number of the book is the same in all three systems: 1905. All systems use the same logic: a prefix is assigned to given entity (company or publisher) who assigns numbers with that prefix, the code of the item and a check symbol. The conversion from ISBN-10 to ISBN-13 is just done by changing the prefix (typically adding 978) and recomputing the check digit.

Here The ISBN block 0-8048 is allocated to Charles E. Tuttle Company, and the UPC prefix 676251 is also assigned to Tuttle Publishing. So the publisher is exporting the same book code (1905) into three systems for the sake of compatibility…

Flattr this!

QR Code pointing to this same blog

The day Bluetooth worked…

Bluetooth Logo

A long time ago, I remember reading an article discussing the advent of broadband, and which technology would dominate: DSL or Cable. The author of the article made an interesting point, technically, cable was better, as a coax cable can carry way more data than a phone cable, yet he predicted that DSL would dominate.

His reasoning was that telecom companies had decades to do any possible mistakes and stupid designs for data transmissions, while the cable companies were new at this. His prediction turned out pretty true, at home I have a DSL connection, and they are pretty common. Optical fibre, which is technically the best data carrier, is still the exception.

People working in software tend to underestimate the amount of time and work to get a new N to N system working in the field. Writing good specifications is very hard, and it takes multiple iterations to get all the implementations to work nicely together and to clean up all edge cases. This is why data formats and network protocols tend to live much longer that software.

QR Code pointing to this same blog

Recently I used the same argument to explain why NFC would not work well for a few years, and certainly not supplant Bluetooth. Bluetooth is now 15 years old, so people have plenty of experience about bad drivers and complicated compatibility issues. This also means that Bluetooth now works: I regularly use Bluetooth HID devices (mice and keyboards), Bluetooth internet tethering on my on-call phone, my iPhone syncs with the stereo system of rental cars and external speakers just work. In contrast, NFC as only been deployed in closed loop systems: public transport tickets mostly, where there is a limited number of suppliers and a single entity overseeing the deployment.

In a sense NFC is not competing with Bluetooth, but with barcodes: most of the contact-less data transmission that I have used these days does not involve radio-signals, but an mobile phone app displaying a QR code to a scanner. Again, this is way less efficient than transmitting a radio-signal, but QR codes are a mature technology that have been deployed widely since the nineties.

Flattr this!

Les codes barres de la Migros

Ticket de caisse Migros n° 0020419214101300003695

Il y a quelques temps, j’ai écrit deux billets sur les codes barres de la Coop. Aujourd’hui je vais vous parler de quelque chose de complètement différent : les codes barres de la Migros. En particulier ceux que l’on trouve sur les tickets de caisse. Comme pour la Coop ils sont encodés au format Interleaved 2 of 5, avec une série de champs à longueur fixe. Contrairement à la Coop, la Migros n’utilise pas le préambule 99 et d’une manière générale utilise une disposition et des champs très différents.


Les trois premiers chiffres représentent le numéro de caisse, ils sont suivi par le numéro de transaction sur cinq chiffres, suivi par le jour du mois sur deux chiffres, puis l’heure, encodée sur quatre chiffres. J’ai été surpris de voir que le mois et l’année ne sont pas encodés, je suppose qu’ils peuvent être déduis d’une manière ou d’une autre à partir du numéro de transaction et de caisse. Comme la paire 〈 n° de caisse, n° de transaction 〉 occupe aussi une place importante dans le système de la Coop, je soupçonne que c’est la clef primaire du système. Les huit derniers chiffres sont le montant en centimes, on admirera le fait que le système permette des transactions jusqu’à CH₣ 999’999.95, faire ses courses à la Migros pour un million, c’est le rêve de tout à chacun.

Flattr this!