How do you convert 12-digit UPC-A to 13-digit EAN-13 and 14-digit GTIN-14 losslessly?
In the GS1 standard, UPC-A (GTIN-12) is a strict subset of EAN-13 (GTIN-13). Prepending a single leading '0' to a valid 12-digit UPC-A produces an identical-check-digit 13-digit EAN-13 without altering Mod-10 math. Prepending another '0' (packaging indicator 0) yields the standard 14-digit GTIN-14 retail unit. Conversely, only EAN-13 codes starting with '0' can be converted back into 12-digit UPC-A.