Question

I need a QR code library to encode only numeric values. QR code with only numeric values can store up to 7089 characters, alphanumerics - 4296. As far i have searched i can found libs with ability to encode only alphanumeric or binary values. Except one - BarcodeLib: http://www.barcodelib.com/ which is realy costly.

So i need free library which could encode only numeric data and store up to 7089 digits. The most useful would be java libraries, but python or .net ones are also welcome.

Was it helpful?

Solution

Far as I know the QR Code library originated in Japan and is in C++, a copy is in Github look for the Kuapay IOS source code..... imbedded in the package is a QRDraw folder with 6 source codes,

the one you are interested in and the one you eventually call by some way is QR_Encode if you look at the header (QR_Encode.h) you can see the following:

===============
// åÎÇËí˘ê≥ÉåÉxÉã
   #define QR_LEVEL_L   0
   #define QR_LEVEL_M   1
   #define QR_LEVEL_Q   2
   #define QR_LEVEL_H   3

 // ÉfÅ[É^ÉÇÅ[Éh
    #define QR_MODE_NUMERAL  0
    #define QR_MODE_ALPHABET    1
    #define QR_MODE_8BIT     2
    #define QR_MODE_KANJI    3

// ÉoÅ[ÉWÉáÉì(å^î‘)ÉOÉãÅ[Év
  #define QR_VRESION_S  0 // 1 Å` 9
  #define QR_VRESION_M  1 // 10 Å` 26
  #define QR_VRESION_L  2 // 27 Å` 40

  #define MAX_ALLCODEWORD    3706 
      // ëçÉRÅ[ÉhÉèÅ[Éhêîç≈ëÂíl
  #define MAX_DATACODEWORD 2956 
     // ÉfÅ[É^ÉRÅ[ÉhÉèÅ[Éhç≈ëÂíl(ÉoÅ[ÉWÉáÉì40-L)
  #define MAX_CODEBLOCK   153 
     //  ÉuÉçÉbÉNÉfÅ[É^ÉRÅ[ÉhÉèÅ[Éhêîç≈ëÂíl(ÇqÇrÉRÅ[ÉhÉèÅ[ÉhÇä‹Çfi)
  #define MAX_MODULESIZE      177 
      // àÍï”ÉÇÉWÉÖÅ[Éãêîç≈ëÂíl

  #define QR_MARGIN 4

the comments are in Japanese, so it takes a while for things to sink in, from what I understand in the source code

you invoke the encoding process via this command:

CQR_Encode encoder;
encoder.EncodeData(1, 0, true, -1, str);

(1 actually refers to the QR Level (Reed Solomon Error Correction Level), in this case M (RS error correction) 0 is QR Version S (Small size?) true is a boolean value for auto extend and -1 is an obscure parameter called masking_no that I still have not figured out how it fits into all these and str is the string that you want to create into a QR Code.

From the source code, it actually evaluates the string to check if it is numeric, alphabet (all caps), Kanji or 8 bit (mixed caps), and then decides the max length and the encoding/compression method.

So the answer to your question is - if this is the actual japanese code that is basis for the rest of the SDK then just ensure that the string you pass is really numeric and it will figure it out and allow passing of longer strings. You probably want to use version 2 (L) and although not advisable you may want to lower the EC Level to L (0) to create less redundancy and increase your maximum no of characters (ps the number you quoted requires EC of L.

I hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top