micjahn / ZXing.Net

.Net port of the original java-based barcode reader and generator library zxing
Apache License 2.0
2.65k stars 662 forks source link

Binary data support #264

Open sergeykorobeynikov opened 4 years ago

sergeykorobeynikov commented 4 years ago

I can not find the possibility of encoding binary data (byte[] instead string). Encoding data into a string is not a solution, if only because of the use of control characters.

var writer = new DataMatrixWriter();
//writer.encode()
public BitMatrix encode(string contents, BarcodeFormat format, int width, int height, IDictionary<EncodeHintType, object> hints);
public BitMatrix encode(string contents, BarcodeFormat format, int width, int height);

Why only string supported?

micjahn commented 4 years ago

I think that is a historical reason. This port is based on the original java version. I have no idea why there was that decision. Perhaps because the first implemented codes don't support binary data (like EAN, UPC, etc.). I think in the past I used ISO8859-1 or ISO8859-15 for string encoding of binary data. As far as I remember it worked for every byte from 0 to 255.

sergeykorobeynikov commented 4 years ago

This does not allow the use of the library in industrial solutions.