Skip to content

Support GS1 for datamatrix#78

Open
gijsbotje wants to merge 19 commits intomakiuchi-d:masterfrom
gijsbotje:Feature/gs1-support-datamatrix-code128
Open

Support GS1 for datamatrix#78
gijsbotje wants to merge 19 commits intomakiuchi-d:masterfrom
gijsbotje:Feature/gs1-support-datamatrix-code128

Conversation

@gijsbotje
Copy link
Copy Markdown

@gijsbotje gijsbotje commented Dec 25, 2025

As #42 has been stale for years, this adds support for the GS1 hints used by the minimal encoder as implemented in zxing.


Validated using https://play.google.com/store/apps/details?id=com.chaniotisalexandros.gs1barcodescanner and generating the barcodes below using our API.

content in human-readable format:

(01)05391538880109(17)261130(10)28967(21)1049931544602459836

Before:
invalid gs1 datamatrix

After:
valid gs1 datamatrix

@makiuchi-d
Copy link
Copy Markdown
Owner

Thank you for the contribution.
Does this PR add functionality that is not present in the original ZXing?

@gijsbotje
Copy link
Copy Markdown
Author

gijsbotje commented Dec 29, 2025

@makiuchi-d not for the datamatrix. I implemented the minimal encoder, like you suggested.

I couldn't find an actual prepend for the code128 in the original ZXing. Do you need me to remove it?

If anything else needs to change let me know!

@gijsbotje gijsbotje changed the title Support GS1 prefix for datamatrix and code128 Support GS1 for datamatrix Dec 30, 2025
@gijsbotje
Copy link
Copy Markdown
Author

@makiuchi-d i removed the code128 changes as they are not mirroring ZXing's implementation.

@makiuchi-d
Copy link
Copy Markdown
Owner

@gijsbotje
Happy New Year!
Thank you for the great contribution.
I'm checking it now and will merge it after that.
Please wait for a while.

@makiuchi-d
Copy link
Copy Markdown
Owner

I added some tests and fixed a bug in how character encoding is handled.
Since string indexing in Go is not character-based, it needs to be converted to []rune. Also, encoded byte sequences shouldn’t be treated as strings or runes.

The HighLevelEncoder naming (which I wrote) wasn’t very consistent either, but I fixed some inconsistent naming in MinimalEncoder. Was that written by AI, by any chance?

I’ll add a few more tests and plan to merge if everything looks good.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 82.44186% with 151 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.37%. Comparing base (95e256b) to head (0e62da5).

Files with missing lines Patch % Lines
datamatrix/encoder/minimal_encoder.go 79.96% 72 Missing and 32 partials ⚠️
datamatrix/datamatrix_writer.go 21.05% 27 Missing and 3 partials ⚠️
common/minimal_eci_input.go 92.16% 5 Missing and 8 partials ⚠️
datamatrix/encoder/high_level_encoder.go 86.95% 1 Missing and 2 partials ⚠️
common/eci_encoder_set.go 98.79% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #78      +/-   ##
==========================================
- Coverage   97.93%   96.37%   -1.56%     
==========================================
  Files         122      126       +4     
  Lines       12951    11352    -1599     
==========================================
- Hits        12684    10941    -1743     
- Misses        191      291     +100     
- Partials       76      120      +44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gijsbotje
Copy link
Copy Markdown
Author

@makiuchi-d anything I can do to help?

@makiuchi-d
Copy link
Copy Markdown
Owner

@gijsbotje
Sorry for the delay -- I haven't had much time recently, but I'm still working on the review.

If possible, it would really help if you could also port GS1 support for DataMatrixReader so we can cross-verify with the Writer.

@gijsbotje
Copy link
Copy Markdown
Author

@makiuchi-d i've tried adding the support and added a test with the image from my initial comment. Hopefully it's all correct :)

@gijsbotje
Copy link
Copy Markdown
Author

@makiuchi-d anything else i can do to help you out on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants