Tim Tim - 4 days ago 5
Android Question

Output barcode control codes using ZXing?

Without changing any ZXing source code, is there a way to output control codes in a barcode using ZXing on Android?

Edit: The reason that I don't want to edit source code is because I would like to use the "scan via intent" process. If I have to edit source, then I'll have to embed the entire project into my project instead.

For instance, I have a GS1-128 barcode that currently outputs text

21417341123
. I would instead like to see something like
[Start C][FNC1]21417341123[Stop]
.

If I can get the raw data from the scan, that would also be OK. But the "rawBytes" value is only for the data (21417341123 portion) and doesn't include the control codes. I saw the question ZXing Result.getRawBytes(), what exactly is it?, but the solution to use
getByteArrayExtra("SCAN_RESULT_BYTE_SEGMENTS_0");
returns
null
.

If it is not possible to do this without changing code, then I will need to modify the ZXing source. I am just trying to see if I can do what I want without modifying source.

Answer

Usually when people ask this question, they are talking about FNC codes in a format like Code 128. These don't have a printable representation in the result, although FNC1 is translated as "]C1" or ASCII 29 as per the spec. The others really don't correspond to anything in the output, so don't result in any characters.

It looks like you're asking about a "START C" code. This too really isn't part of the string encoded by the barcode. It's an internal marker that tells it to switch sets for parsing the rest of the barcode.

Raw bytes make a bit more sense for other formats where there is clearly an underlying byte representation that is then further translated. For Code 128 it will give you all the (non-control) codes found in the barcode rather than the interpreted string. This is not what you want.

For your purpose you would have to modify the code. I think this only makes sense for some artificial use case .

Comments