How to convert UPC-E barcode to UPC-A barcode?

What is the algorithm for converting the zero-suppressed eight-digit GTIN-12 (represented as a UPC-E barcode) to the full twelve-digit version as shown in the UPC-A barcode?

Is there a way to achieve this for a small number of barcodes without writing any code?

+3


source to share


1 answer


The algorithm for converting a GTIN-12 identifier between UPC-E and UPC-A representation can be most clearly seen from the following template display:

SabcdeNX ⟺ SabN0000cdeX  :  0≤N≤2
Sabcde3X ⟺ Sabc00000deX
Sabcde4X ⟺ Sabcd00000eX
SabcdeNX ⟺ Sabcde0000NX  :  5≤N≤9

      

In the above S

is a system of numbers, either 0 or 1, and X

is a check digit.



In pseudocode, it looks like this:

Input:  A valid eight-digit UPC-E: Assigned to E[]. 
Output: PASS: Twelve-digit UPC-A representing the UPC-E.
        FAIL: Reason.

if E[0] != {0-1} then FAIL: Invalid number system.

if E[6] == {0-2} then PASS: E[0-2] . E[6] . "0000"  . E[3-5] . E[7]
if E[6] == "3"   then PASS: E[0-3] .        "00000" . E[4-5] . E[7]
if E[6] == "4"   then PASS: E[0-4] .        "00000" . E[5]   . E[7]    
if E[6] == {5-9} then PASS: E[0-5] .        "0000"  . E[6]   . E[7]

      

+9


source







All Articles