Repository navigation
fix: translate Codabar start/end characters when ReturnCodabarStartEnd is set - #113
Merged
Merged
Conversation
…d is set CodaBarReader translated alphabet indices into a copy and stored the copy only when the start/end characters were stripped. With ReturnCodabarStartEnd the result text was the raw indices, e.g. "\x10\x01\x02\x03\x04\x11" for A1234B. ZXing translates in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hschimke
approved these changes
Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
DecodeHintValue::ReturnCodabarStartEnd(true),CodaBarReaderreturns internal alphabet-table indices instead of characters. Default decoding, which strips the start and end characters, is correct.To reproduce:
Cause
CodaBarReader::decode_rowcollects alphabet indices indecodeRowRXingResult, then translates them into characters in a local copy,cached_drrr. That copy is written back only in the branch that strips the start and end characters. With the hint set, the untranslated indices become the result text.ZXing translates
decodeRowResultin place, so this is specific to the Rust port.Fix
Store the translated characters in both cases: the whole string when the hint is set, the inner characters otherwise.
Test
This PR adds
testDecodeWithStartEndtoCodaBarWriterTestCase, behindfeature = "decoders". It encodesA1234BandC-$:/.+Dand decodes each one with and without the hint.Without the fix, it fails:
With the fix, it passes.
I also decoded all 16 start/stop pairs (A–D × A–D) from a separate encoder. With the hint,
mainreturns the right text for 0 of 16 and this branch for 16 of 16. Without the hint, both return the right text for 16 of 16.Both CI test steps,
cargo test --workspace --releaseand the same with--no-default-features, pass on this branch.I found this while using rxing to check a barcode encoder by decoding its output. The change and this description were prepared with AI assistance (Claude, via Claude Code). I reviewed the change and the test results before opening this PR. It is contributed under the Apache License 2.0.
🤖 Generated with Claude Code