1
0
Fork
You've already forked python-barcode
0

GS1 always starts with Character Set B #110

Open
opened 2021年06月24日 00:35:11 +02:00 by noperator-zz · 2 comments
noperator-zz commented 2021年06月24日 00:35:11 +02:00 (Migrated from github.com)
Copy link

Some codes can be encoded entirely with code C, but Code128() initializes self._charset = "B" unconditionally.
Also, due to the (non-numeric) FNC 1 character at the start of a GS1 barcode, the library will always start with character set B anyway, even if self._charset was set to "C". WhyNotHugo/python-barcode@83a0b4e877/barcode/codex.py (L175)

The effect is that a switch to Code C is added after FNC 1, when it could have just started with character set C instead.

Expected (ignore the slash):
START C -> FNC 1 -> 12 -> 00 -> 13 -> 00 -> 85
image

Actual:
START B -> FNC 1 -> CODE C -> 12 -> 00 -> 13 -> 00 -> 85
gs128

import barcode
from barcode.writer import ImageWriter
sn = 1200130085
# START B -> FNC 1 -> CODE C -> barcode (code C)
code = barcode.get("gs1_128", str(sn), writer=ImageWriter())
code.save("gs128")
Some codes can be encoded entirely with code C, but Code128() initializes self._charset = "B" unconditionally. Also, due to the (non-numeric) FNC 1 character at the start of a GS1 barcode, the library will always start with character set B anyway, even if self._charset was set to "C". https://github.com/WhyNotHugo/python-barcode/blob/83a0b4e87755f8dcb22c9cf35c52f6f3ae7a6993/barcode/codex.py#L175 The effect is that a switch to Code C is added after FNC 1, when it could have just started with character set C instead. Expected (ignore the slash): START C -> FNC 1 -> 12 -> 00 -> 13 -> 00 -> 85 ![image](https://user-images.githubusercontent.com/12838439/123175242-4cfe7880-d436-11eb-9a30-13fa0162a0dc.png) Actual: START B -> FNC 1 -> CODE C -> 12 -> 00 -> 13 -> 00 -> 85 ![gs128](https://user-images.githubusercontent.com/12838439/123175445-a9fa2e80-d436-11eb-872c-999169cb0348.png) ``` import barcode from barcode.writer import ImageWriter sn = 1200130085 # START B -> FNC 1 -> CODE C -> barcode (code C) code = barcode.get("gs1_128", str(sn), writer=ImageWriter()) code.save("gs128") ```
audoh-tickitto commented 2021年07月06日 12:21:43 +02:00 (Migrated from github.com)
Copy link

Similar issue with Code128, it starts with charset B so it will never switch to charset A as A is a subset of B (for alphanumeric barcodes, at least).

I think there are some characters in charset A which are not included in charset B, so I think we will just need something a bit more sophisticated (both for GS1 and Code128) than just starting in one charset and changing if that does not support.

I sort of think we should just have these exposed via the constructor, with automatic resolution used only if not explicitly specified there.

Similar issue with Code128, it starts with charset B so it will never switch to charset A as A is a subset of B (for alphanumeric barcodes, at least). I think there are some characters in charset A which are not included in charset B, so I think we will just need something a bit more sophisticated (both for GS1 and Code128) than just starting in one charset and changing if that does not support. I sort of think we should just have these exposed via the constructor, with automatic resolution used only if not explicitly specified there.
WhyNotHugo commented 2021年07月16日 14:27:05 +02:00 (Migrated from github.com)
Copy link

Yup, makes sense. The "next charset" should be evaluated at the rather than hardcoded.

Yup, makes sense. The "next charset" should be evaluated at the rather than hardcoded.
Sign in to join this conversation.
No Branch/Tag specified
main
pre-commit-ci-update-config
extensibility
fix_sizes
feature/longer_guard_bar
ean-without-checksum
readme-formatting
cleaning
cleanup
srolin/master
michieldwitte/left-alignment-fix
v0.13.1
v0.13.0
v0.12.0
v0.11.0
v0.10.0
v0.9.0
v0.8.3
v0.8.2
v0.8.1
v0.8.0
0.8beta1
0.7
0.7beta4
0.7beta3
0.7beta2
v0.6
v0.6b3
v0.6b2
v0.6b1
v0.5.0
v0.5.0b1
v0.4.3
v0.4.2
v0.4.1
v0.4
v0.4b2
v0.4b1
v0.3
v0.3b1
v0.2.1
v0.1
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
WhyNotHugo/python-barcode#110
Reference in a new issue
WhyNotHugo/python-barcode
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?