I use this patch. Binary data support is useful for 4096 bit gpg keys and such where base64 leads to 165x165 grid and raw binary yields a 137x137 grid. The zbarimg test still fails, but the zxing barcode reader works now. I believe zbarimg also must make assumptions about zero-terminated strings.
diff -pru a/qrenc.c b/qrenc.c --- a/qrenc.c 2011-08-30 12:59:14.691855553 -0400 +++ b/qrenc.c 2011-08-30 13:01:47.467852948 -0400 @@ -122,7 +122,7 @@ static void usage(int help, int longopt) } #define MAX_DATA_SIZE (7090 * 16) /* from the specification */ -static char *readStdin(void) +static char *readStdin(int *len) { char *buffer; int ret; @@ -143,6 +143,7 @@ static char *readStdin(void) } buffer[ret] = '\0'; + if( len ) *len = ret; return buffer; } @@ -246,12 +247,19 @@ static int writePNG(QRcode *qrcode, cons return 0; } -static QRcode *encode(const char *intext) +static QRcode *encode(int len, const char *intext) { - QRcode *code; + QRcode *code = NULL; + + if( !intext ) return NULL; if(eightbit) { - code = QRcode_encodeString8bit(intext, version, level); + QRinput *input = QRinput_new2(version, level); + if(input) { + int ret = QRinput_append(input, QR_MODE_8, len, (unsigned char *)intext); + if(ret >= 0) code = QRcode_encodeInput(input); + QRinput_free(input); + } } else { code = QRcode_encodeString(intext, version, level, hint, casesensitive); } @@ -259,11 +267,11 @@ static QRcode *encode(const char *intext return code; } -static void qrencode(const char *intext, const char *outfile) +static void qrencode(int len, const char *intext, const char *outfile) { QRcode *qrcode; - qrcode = encode(intext); + qrcode = encode(len,intext); if(qrcode == NULL) { perror("Failed to encode the input data:"); exit(EXIT_FAILURE); @@ -272,12 +280,23 @@ static void qrencode(const char *intext, QRcode_free(qrcode); } -static QRcode_List *encodeStructured(const char *intext) +static QRcode_List *encodeStructured(int len, const char *intext) { - QRcode_List *list; + QRcode_List *list = NULL; if(eightbit) { - list = QRcode_encodeString8bitStructured(intext, version, level); + QRinput *input = QRinput_new2(version, level); + if(input) { + int ret = QRinput_append(input, QR_MODE_8, len, (unsigned char *)intext); + if(ret >= 0) { + QRinput_Struct *s = QRinput_splitQRinputToStruct(input); + if( s ) { + list = QRcode_encodeInputStructured(s); + QRinput_Struct_free(s); + } + } + QRinput_free(input); + } } else { list = QRcode_encodeStringStructured(intext, version, level, hint, casesensitive); } @@ -285,7 +304,7 @@ static QRcode_List *encodeStructured(con return list; } -static void qrencodeStructured(const char *intext, const char *outfile) +static void qrencodeStructured(int len, const char *intext, const char *outfile) { QRcode_List *qrlist, *p; char filename[FILENAME_MAX]; @@ -305,7 +324,7 @@ static void qrencodeStructured(const cha } } - qrlist = encodeStructured(intext); + qrlist = encodeStructured(len,intext); if(qrlist == NULL) { perror("Failed to encode the input data:"); exit(EXIT_FAILURE); @@ -432,11 +451,13 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } + int len=-1; if(optind < argc) { intext = argv[optind]; + len = (int)strlen(intext); } if(intext == NULL) { - intext = readStdin(); + intext = readStdin(&len); } if(structured) { @@ -444,9 +465,9 @@ int main(int argc, char **argv) fprintf(stderr, "Version must be specified to encode structured symbols.\n"); exit(EXIT_FAILURE); } - qrencodeStructured(intext, outfile); + qrencodeStructured(len,intext, outfile); } else { - qrencode(intext, outfile); + qrencode(len,intext, outfile); } return 0; Only in b: .qrenc.c.swp