robbiepaul / zbar-qrdecoder

A PHP wrapper for Zbar. Decodes images/photos containing QR codes.
32 stars 38 forks source link

Wrapper result returning additional "\n" at the end of return of QRCode. #2

Closed alpha1125 closed 9 years ago

alpha1125 commented 9 years ago

Image of QR Code

Result should be "New Document"

Observed result: "New Document\n"

Suggestion: Have zbarimg return back XML. Parse resulting XML, as the result is wrapped as:

$> zbarimg -q -D --xml qrcode.27486477.png

where qrcode.27486477.png, is supposed to be "Document Separator"

<barcodes xmlns='http://zbar.sourceforge.net/2008/barcode'>
  <source href='qrcode.27486477.png'>
    <index num='0'>
      <symbol type='QR-Code' quality='1'><data><![CDATA[Document Separator]]></data></symbol>
    </index>
  </source>
</barcodes>

Since the <![CDATA[ is collecting the actual string, we can use that. We cannot "trim", as sometime the QR may have the \n at the end, which may be needed.

robbiepaul commented 9 years ago

Thanks for pointing this out! I've implemented your suggestion in the latest commit (539332244e8779eea5b07093aa9b290b964d944c)