hxdai
hxdai

Reputation: 53

Encode numeric string as alphanumeric in ZXing.Net

I'm building an app that requires encoding of a 16-digit all-numerical string, using ZXing.Net, if I do the following:

ZXing.Common.EncodingOptions qr_options = new ZXing.Common.EncodingOptions();
qr_options.Width = 144;
qr_options.Height = 144;
qr_options.Hints.Add(ZXing.EncodeHintType.DISABLE_ECI, true);
IBarcodeWriter qr_wr = new BarcodeWriter() { Format = BarcodeFormat.QR_CODE, Options = qr_options};

OutputImg = (WriteableBitmap)qr_wr.Write(MyAllNumberString).ToBitmap();

I'm getting a QR code that's encoded as numerics, which generates a different raw byte array. Is there a setting somewhere that I need to set, so that the numeric string is encoded as alphanumeric string?

Upvotes: 0

Views: 1367

Answers (1)

hxdai
hxdai

Reputation: 53

I ended up building ZXing.net from source, and modified the source code. There is a function inside ZXing.net that checks your input string to be encoded, if that string contains only numeric characters, it will set the encoding mode of QR code to NUMERICAL. I added an option to force it to be encoded as ALPHANUMERICAL. I'll post a link to changes I made later. I have raised this issue to ZXing.Net's owner but they seem lukewarm to the solution I proposed.

Upvotes: 1

Related Questions