AndyPanda95 / python-for-android

Automatically exported from code.google.com/p/python-for-android
Apache License 2.0
0 stars 0 forks source link

When scanning a barcode, SCAN_RESULT_BYTES is a king of strange unicode string #63

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create DataMatrix (and probably QR will fail too) barcode with binary 
encoding. You may use http://www.bcgen.com/datamatrix-barcode-creator.html with 
"process tilda" option and some binary data.
2. Try to run following script:

import android
droid = android.Android()
code = droid.scanBarcode()
bts = code.result['extras']['SCAN_RESULT_BYTES']
sr =  code.result['extras']['SCAN_RESULT']

print type(bts)
print len(bts)
print sr

What is the expected output? What do you see instead?

We surely expect array (list, string, anything other at least Iterable) of 
bytes. With the length equal to number of bytes in the barcode. And we expect 
scan result to be something like byte string with the same length.

Instead we have everything in unicode strings. SCAN_RESULT is unicode strings 
containing comma-separated byte values (great =)) and SCAN_RESULT_BYTES is 
unicode string of some strange length (I suppose it tries to decode it from 
UTF8 leaving failed bytes in place).

What version of the product are you using? On what operating system?

I use Android 2.3.7 (MiniCM7, Xperia X8) and Python for Android of rev 4 
installed with SL4A.

Please provide any additional information below.

I suspect that giving out comma-separated string as SCAN_RESULT can be ZXing's 
feature, so I think we can leave it as is, but SCAN_RESULT_BYTES should 
definitely not be unicode string.

Original issue reported on code.google.com by dlu...@gmail.com on 25 Oct 2012 at 8:38

GoogleCodeExporter commented 8 years ago
I am very sorry, the part about "comma separated" string is completely wrong (I 
have formatted input string incorrectly).

So the only remain is about SCAN_RESULT_BYTES type.

Original comment by dlu...@gmail.com on 25 Oct 2012 at 9:34