Package: libzbar0 Version: 0.10+doc-7+b2 As it was pointed out [1] by Ben Morrow in a recent news:comp.lang.perl.misc thread, libzbar0 appears to assume ISO-8859-1 encoding for the input QR-encoded 8-bit data, and attempts to unconditionally recode it into UTF-8, thus giving (possibly) incorrect results.
The issue arises with both the zbarimg(1) command-line tool (which disregards the locale currently in effect), and the Perl's Barcode::ZBar interface (suggesting that the resulting UTF-8-coded string is not being properly passed back to the calling Perl code.) As was suggested, I've used the “level L” Imager::QRCode option and a test vector of 17 ‘\xFF’ octets. As expected, the resulting QR code was 21 by 21 dots, thus ruling out the possibility of ISO-8859-1 to UTF-8 expansion happening within the generating Imager::QRCode module. Consider, e. g. (the code is MIME'd): $ LC_ALL=C perl -- z97wbjf3xptrg36ymsrczz5ggy.perl Blob: pack("H*","ffffffffffffffffffffffffffffffffff") Image: 42 by 42 [["QR-Code", ("\xC3\xBF" x 17)]] $ Where \xC3\xBF's are ISO-8859-1 \xFF's recoded into UTF-8: $ printf \\xc3\\xbf \ | iconv -f UTF-8 -t ISO-8859-1 \ | od -t x1 0000000 ff 0000001 $ [1] news:u0m61a-t5i1....@anubis.morrow.me.uk -- FSF associate member #7257
### z97wbjf3xptrg36ymsrczz5ggy.perl -*- Perl -*- ## A simplistic Imager::QRCode vs. Barcode::ZBar test. ### Ivan Shmakov, 2013 ## To the extent possible under law, the author(s) have dedicated all ## copyright and related and neighboring rights to this software to the ## public domain worldwide. This software is distributed without any ## warranty. ## You should have received a copy of the CC0 Public Domain Dedication ## along with this software. If not, see ## <http://creativecommons.org/publicdomain/zero/1.0/>. ### Code: use common::sense; require Barcode::ZBar; require Data::Dump; require Imager::QRCode; my $qr = Imager::QRCode->new (qw (mode 8-bit casesensitive 1), qw (level L margin 0 size 2)); my $blob = pack ("H*", ("FF" x 17)); print ("Blob: ", Data::Dump::dump ($blob), "\n"); my $img = $qr->plot ($blob); print ("Image: ", $img->getwidth (), " by ", $img->getheight (), "\n"); my $jpeg = undef; $img->write ("data" => \$jpeg, "type" => "jpeg") or die (); my $bi = Barcode::ZBar::Image->new (); $bi->set_format ("JPEG"); $bi->set_size ($img->getwidth (), $img->getheight ()); $bi->set_data ($jpeg); my $reader = Barcode::ZBar::Processor->new(); $reader->process_image($bi); my @xsym = map { ## . [ $_->get_type (), $_->get_data () ]; } ($bi->get_symbols ()); print ("", Data::Dump::dump ([ @xsym ]), "\n"); ### Emacs trailer ## Local variables: ## coding: us-ascii ## fill-column: 72 ## indent-tabs-mode: nil ## ispell-local-dictionary: "american" ## End: ### z97wbjf3xptrg36ymsrczz5ggy.perl ends here