Convert EAN-8 to EAN-13 - barcode

I have an 8 digit EAN code which I would like to convert to an EAN-13 code.
Do you know of any algorithm on how to calculate this?
Or is it simply adding five zeros to the beginning of the EAN-8?
E.g. EAN-8(1234 5678) becomes EAN-13(00000 1234 5678)?

Adding five leading zeros to a valid EAN-8 will give you a valid EAN-13.
EAN-8 is just another name for GTIN-8, and EAN-13 is another name for GTIN-13. You can always convert shorter GTINs to longer GTINs by left-padding them with zeros, see http://en.wikipedia.org/wiki/Global_Trade_Item_Number#Format.

EAN-8 is a short version of EAN-13, composed by 7 digits and 1 check digit.
There is no conversion available between EAN-8 and EAN-13 sorry :(

Related

ZPL Barcode missing front 2 digit

I am trying to print an EAN barcode vertically on a label with below ZPL code:
^FO895,273^BY3^BUB,200,Y,N
^FO895,261^FD9827755779090^FS
I'm expecting the output as 9827755779090. However, it prints out as 277557790900.
It cuts off the first 2 digit(98) and adds (0) on the final digit. Can I know how do I fix my code?
^BE is the EAN command. It will calculate the check digit for you.
^BE; EAN-13 Bar Code. Description: The ^BE command is similar to the
UPC-A bar code. It is widely used throughout Europe and Japan in the
retail marketplace. The EAN-13 bar code has 12 data characters, one
more data character than the UPC-A code. An EAN-13 symbol contains the
same number of bars as the UPC-A, but encodes a 13th digit into a
parity pattern of the left-hand six digits. This 13th digit, in
combination with the 12th digit, represents a country code. • ^BE
supports fixed print ratios. • Field data (^FD) is limited to exactly
12 characters. ZPL II automatically truncates or pads on the left with
zeros to achieve the required number of characters.
Here is the fixed code (with changed ^FO).
^XA
^FO95,273^BY3^BEB,200,Y,N
^FD9827755779090^FS
^XZ
You are feeding the barcode more data than the specification is set for.
Plus, you are not creating an EAN code, but a UPC(12).
Specification :
UPC (technically refers to UPC-A) consists of 12 digits
Specification of ZPL II on UPC-A (code ^BU) section 5.34 specifically states:
^FD : exactly 11 characters. ZPL II auto-truncates or pads ON THE LEFT with 0 to achieve required number of characters.
(I added italics)
So you get
^FO895,261^FD9827755779090^FS
----------- << these 11 digits
It just so happens that the UPC checksum of 27755779090 is 0
This is why you would get same result for ^FO895,261^FD999999988889827755779090^FS
To get exactly what you want, use
^FO895,261^FD98277557790^FS
.. this will get a checksum of 4

GS1-128 ZPL generation with GTIN (01) with only 13 digits

I'd like to generate a GS1-128 barcode like this
(01)5410413901026(17)170612(10)LOT100
in ZPL code
^BY5,3,160^FT372,1506^BCB,,N,N,N
^FD>;>8015410413901026>817170612>810>6LOT100^FS
My problem is the 01 code is normally exactly 14 digits, here my EAN is only 13 digits. So my barcode is misformed.
I have already tried to put >8 at the begin of every new AI without result.
EAN is always 13 digits. Add a leading zero to convert to a 14-digit GTIN. (A digit other than 0 at the start identifies a wholesale container of the item.)
Ref: https://stackoverflow.com/a/56673316/323917
Parentheses and spaces can be in the field data. '00' application identifier, followed by 17 characters, followed by bogus check digit place holder.
Ref: https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf
I have verified the barcode from https://zxing.org/w/decode and https://online-barcode-reader.inliteresearch.com/

Decoded barcode extra digits

I am trying to come to terms with how a barcode is decoded and generated by a scanner.
A note from the client says the following generated bar code consists of extra characters:
Generated Code: |2389299920014}
Extra Characters: Apparently the first two and last three characters are not part of the bar code.
Question
Are the extra characters attached by the bar code reader (therefore dependent on the scanner) or are they an intrinsic part of the barcode?
Here is a sample image of a barcode:
http://imageshack.us/a/img824/1862/dm6x.jpg
Thanks
[SOLVED] My apologies. This was just another one of those cases of 'shooting your mouth off' without doing proper research.
Solution The code is EAN13. The prefix and suffix are probably scanner dependent. The 13 digits in between are as follows (first digit from the left) Check Sum (Next 9 digits) Company Id + Item Id (Last 3 Digits ) GS1 prefix
It's hard to answer without understanding what format you are trying to encode, what the intended contents are, and what the purported contents are.
Some formats add extra information as part of the encoding process, but it does not become part of the content. When correctly encoded and decoded, the output should match the input exactly.
Barcodes encode what they encode and there is no data that is somehow part of the barcode but not somehow encoded in it.
EAN-13 has no scanner-dependent considerations, no. The encoding and decoding of a given number is the same everywhere. EAN-13 encodes 13 digits, so I am not sure what the 13 digits "in between" mean.
You mention GS1, which is something else. A family of barcodes in fact. You'd have to say what specifically you are using. The GS1 encodings are likewise not ambiguous or scanner-dependent. You know what you want to encode, you encode it exactly, it's read exactly.

How can I write a regex to find only numbers with four digits?

I am trying to write a regex in Ruby to search a string for numbers of only four digits. I am using
/\d{4}/ but this is giving me number with four and more digits.
Eg: "12345-456-6575 some text 9897"
In this case I want only 9897 and 6575 but I am also getting 1234 which has a length of five characters.
"12345-456-6575 some text 9897".scan(/\b\d{4}\b/)
=> ["6575", "9897"]
Try matching on a word boundary (\b) on both sides of the four digit sequence:
s = '12345-456-6575 some text 9897'
s.scan(/\b\d{4}\b/) # => ["6575", "9897"]
You have to add one more condition to your expression: the number can only be returned if there are 4 digits AND both the character before and after that 4-digit number must be a non-number.
or even more generally: anything but a digit before and/or after the four digits:
/\D\d{4}\D/
Try /[0-9][0-9][0-9][0-9][^0-9]/
You should specify a separator for the pattern. As in if the digits would be preceded and followed by a space the REGEX would /\s\d{4}\s/, hope that helps.

regex for matching german postal codes but not a

following string:
23434 5465434
58495 / 46949345
58495 - 46949345
58495 / 55643
d 44444 ssdfsdf
64784
45643 dfgh
58495/55643
48593/48309596
675643235
34565435 34545
it only want to extract the bold ones. its a five digit number(german).
it should not match telephone numbers 43564 366334 or 45433 / 45663,etc as in my example above.
i tried something like ^\b\d{5} but thats not a good beginning.
some hints for me to get this working?
thanks for all hints
You could add a negative look-ahead assertion to avoid the matches with phone numbers.
\b[0124678][0-9]{4}\b(?!\s?[ \/-]\s?[0-9]+)
If you're using Ruby 1.9, you can add a negative look-behind assertion as well.
You haven't specified what distinguishes the number you're trying to search for.
Based on the example string you gave, it looks like you just want:
^(\d{5})\n
Which matches lines that start with 5 digits and contain nothing else.
You might want to permit some spaces after the first 5 digits (but nothing else):
^(\d{5})\s*\n
I'm not completely sure about the specified rules. But if you want lines that start with 5 digits and do not contain additional digits, this may work:
^(\d{5})[^\d]*$
If leading white space is okay, then:
^\s*(\d{5})[^\d]*$
Here is the Rubular link that shows the result.
^\D*(\d{5})(\s(\D)*$|()$)
This should (it's untested) match:
line starting with five digits (or some non-digits and then five digits), then
a space, and ending with some non-numbers
line starting and ending with five
digits (or some non-digits and then five digits)
\1 would be the five digits
\2 would be the whole second half, if any
\3 would be the word after the digits, if any
edited to fit the asker's edited question
edit again: I came up with a much more elegant solution:
^\D*(\d{5})\D*$

Resources