buntine / barcoders

A barcode encoding library for the Rust programming language
Apache License 2.0
164 stars 24 forks source link

Serialize arbitrary ASCII string into Code128 barcode? #20

Open ratijas opened 3 years ago

ratijas commented 3 years ago

Currently Code128::new constructor expects valid Code128 byte data, where user must manually specify all the control codes to switch character sets as appropriate.

As a user, I'd rather leverage this conversion onto the library itself. I.e., I expect that I could pass any ASCII string to the constructor, and let it do the magic it needs. Unfortunately, I don't see any such functionality in this crate.

Alternatives

buntine commented 3 years ago

Thanks for the issue. :+1:

Yeah, that's a nice enhancement. I'll look at adding it in the next version of the crate. I'll hopefully get onto it in the next week. I'm also open to PRs!

cheers, Andrew

ratijas commented 3 years ago

Not sure, if this relates to other barcode types. But probably there is a place for a layer of abstractions on top of it. I mean barcode formatted strings.

And for the Code128, the main challenge, as I see it, is that Code128 is able to represent the same data (output) in multiple ways (input strings). It results from the fact that any code page can encode digits and other common symbols. In short: there is no unique way to encode the data in Code128.

Not sure I'm up to the task, but it's nice to see the project moving :)

ratijas commented 2 years ago

Hi, @buntine, what's up? Are you still open to PRs?

jannschu commented 1 year ago

I also needed this and implemented this in a new crate, code128 :-)