fttx / barcode-to-pc-server

Barcode to PC server
https://barcodetopc.com/
GNU General Public License v3.0
207 stars 85 forks source link

Add a "web safe" typed string option #161

Open benvanik opened 6 years ago

benvanik commented 6 years ago

I'm using the app to scan parts into https://partsbox.io - they accept barcodes as keyboard input through the browser. Unfortunately 2D barcodes contain ASCII characters that the browser treats as hotkeys. To enable support for 2D barcodes (via traditional barcode scanners) they support escaping the characters. There's more information here: https://partsbox.io/the-lab/help#other-equipment-and-software

I've been able to get Barcode to PC working with the site by setting a custom typed string to the following:

barcode.replace(//g,"{RS}").replace(//g,"{EOT}").replace(//g,"{GS}")

Since this seems to be a somewhat common convention it'd be nice if there was a checkbox in the app to do this automatically.

jwr commented 6 years ago

I’m the author of PartsBox and I’ll pitch in with more info. The problem is with DataMatrix codes that contain ANSI MH10.8.2 data encoded using ISO/IEC 15434:2006. That’s pretty much every 2D barcode from an electronic parts distributor. There is more information at the very end of PartsBox user guide (https://partsbox.io/users-guide.html).

An external keyboard-wedge type scanner needs to be configured to replace special non-printable characters with ASCII sequences, so that it can work through a browser app. In particular, ASCII codes RS, GS and EOT need to be replaced with strings "{RS}", "{GS}" and "{EOT}", respectively. These ASCII codes will confuse the browsers, each of which will do something unexpected.

BTW, I did not invent those replacements, I looked around and tried to find something to standardize on. This is what SAP uses, so I figured I’d stick to the same replacements.

I think this could be provided as an option. Native apps might not want or need these replacements, but every webapp will need something like this to work.

BTPankow commented 4 years ago

I just wanted to add to this issue with an output template that works for PartsBox. You should just be able to import this and select as your template for future scans.

Just save this .txt file as a .btpt file and open in Barcode To PC. partsbox.txt

It uses the following javascript to do the replacement:

barcode.replace(/\x1e/g, '{RS}').replace(/\x1d/g, '{GS}').replace(/\x04/g, '{EOT}')

This might be useful to add on PartsBox here when mentioning Barcode to PC: https://partsbox.com/users-guide.html#supported-scanners

fttx commented 4 years ago

So this isn't a bug, since some users may want to use those characters as they're, right?

jwr commented 4 years ago

These replacements are only required for scanning into any web browser. Standalone applications do not need (and probably do not want) them.

fttx commented 4 years ago

Ok, thank you. I'll put an article on the web site so that partsbox.io users can easily download the template made by @BTPankow

jwr commented 4 years ago

Thank you, this is much appreciated. Please use "partsbox.com" as the domain, as this is the current and future domain for the app.

I will add more information about Barcode To PC to the User's Manual.

fttx commented 4 years ago

Here it is: https://barcodetopc.com/tutorial/send-barcodes-to-partsbox-using-a-smartphone/