6
$\begingroup$

For example:

Import["http://www.image-share.com/upload/2735/230.jpg"]
BarcodeRecognize@%

can give a String "别看我,我会害羞..." but if I go on using BarcodeImage on the output:

BarcodeImage@%

It will throw a warning:

BarcodeImage called with 1 argument; 2 or 3 arguments are expected.

So how could I use BarcodeImage to make Chinese characters to QR image?

$\endgroup$
  • $\begingroup$ The bug has been repaired in 10.3 $\endgroup$ – yode Dec 30 '15 at 16:26
8
$\begingroup$

The problem seems to be a mixture of three things

  1. You didn't put all the necessary arguments for BarcodeImage
  2. BarcodeImage is limited on text encoding (against standards)
  3. The documentation is poor and does not describe the existing limitation

The good

img = Import["http://www.image-share.com/upload/2735/230.jpg"];
str = BarcodeRecognize@img

"别看我,我会害羞..."

Or as an image for poorly configured devices

Mathematica graphics

So far so good

The bad

Now BarcodeImage needs to be called with two arguments, as the error you got explained.

Then do:

BarcodeImage["text", "QR"]

But not

Mathematica graphics

The second arguments can be any of these:

1D: "UPC", "EAN8", "EAN13", "Code39", "Code128", "ITF", "Codabar"

2D: "Aztec", "DataMatrix", "QR", "PDF417"

The ugly

We get an error even for proper use, and the clue is in the error message

BarcodeImage[str, "QR"]

BarcodeImage::qr: Expecting a string of characters defined in ISO/IEC 8859-1 of length up to 2953, a string of alphanumeric characters of length 4296, or a string of digits of length up to 7089 instead of 别看我,我会害羞.... >>

I guess Chinese characters are not encoded in ISO/IEC 8859-1.

Shamefully the documentation says nothing about encoding limitations. This is very unfortunate implementation from Mathematica, QR codes are supposed to accept various encodings .

Workaround

Wolfram alpha doesn't seem to have that limitation

WolframAlpha["QR code \"别看我,我会害羞...\""]

Mathematica graphics

So you can get a clean output by

chineseQR[str_String] :=  WolframAlpha["QR code \"" <> str <> "\"", {{"QRCodeBarcode", 1}, "Content"}]

And for future use:

chineseQR[str]

Mathematica graphics

| improve this answer | |
$\endgroup$
  • $\begingroup$ oh,Just had the same idea with you when I reopen the browser.I think this is a good idea.just as an old saying goes:心有灵犀一点通. $\endgroup$ – partida Oct 24 '14 at 8:49
  • 1
    $\begingroup$ @user15961, Probably you could write to Wolfram Technical Support requesting full implementation in future releases. In Mathematica > Help > Give Feedback... $\endgroup$ – rhermans Oct 24 '14 at 9:36
  • $\begingroup$ Yeah,I will feedback this problem to them. $\endgroup$ – partida Oct 24 '14 at 9:38
3
$\begingroup$

yes, we can do this way:

 barcodeImage[x_String] :=ImageCrop@Image@Rasterize@WolframAlpha["QR code:" <> x,{{"QRCodeBarcode", 1}, "Content"}];

and then

barcodeImage@"中文"
BarcodeRecognize@%(*Chinese*)

will return the result!

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.