lindell / JsBarcode

Barcode generation library written in JavaScript that works in both the browser and on Node.js
http://lindell.me/JsBarcode
MIT License
5.49k stars 1.11k forks source link

Code 39 Asterisk #322

Open noproblemoh opened 4 years ago

noproblemoh commented 4 years ago

I am trying to generate a CODE39 bar code that contains an asterisk but it generates this error => 0x800a139e - JavaScript runtime error: "W20121921377700*" is not a valid input for undefined

I read somewhere that the character is used to delimit the field being converted and that's why it throws the error but I'm not sure how to get around it. Is there a way to escape the asterisk so it doesn't blow up in conversion?

wodin commented 4 years ago

Hi

"CODE-39" does not support the asterisk character.

Does your barcode actually contain the asterisk at the end or is it just printed as part of the text?

Maybe all you need to do is specify the asterisk manually in the text but leave it out of the data?

JsBarcode("#barcode", "W20121921377700", {
  format: "CODE39",
  text: "W20121921377700*"
});

"Full ASCII CODE-39" does support any ASCII character, but it seems that JsBarcode does not support Full ASCII CODE-39.

Since Full ASCII CODE-39 seems just to be an encoding that uses two characters for the characters not supported by "CODE-39" it might be possible to manually include the two-character sequence for "*" in the data and then manually specify the text using an asterisk instead of the two-character sequence.

JsBarcode("#barcode", "W20121921377700/J", {
  format: "CODE39",
  text: "W20121921377700*"
});

Of course, if your barcode scanner is expecting CODE-39 instead of Full ASCII CODE-39 then it will read "/J" instead of "*". But as far as I can tell that's just the way Full ASCII CODE-39 works.

sl1u16 commented 3 years ago

For me, it was the Non-breaking space screwed everything.