[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using HTTPAPI to generate QR-Codes
Hello,
I'm trying to use HTTPAPI to generate QR-codes. I use Scott Klement's
article "Generate QR Code Mobile Tag from RPG".
Here is my little program:
/define WEBFORMS
/copy HTTPAPI_H
/copy text_p
*
d Msg s 52a varying
d form s like(WEBFORM)
d dataIn s 4296a varying
d dataOut s 4296a varying
d enc_data s *
d enc_data_len s 10i 0
d rc s 10i 0
d constantPart s 1000a varying
d artNumber s 10a varying
d len s 10i 0
/free
*inlr = *on;
// data = 'Type data to go in QR Code here.';
constantPart =
'[1]http://www.xxxxxxx.ch/advanced_search_result.php';
constantPart += '?txtSearchArtnr=';
artNumber = '39701602';
dataIn = constantPart + artNumber;
TEXT_setIconvCcsid(500: 1208); // EBCDIC - > UTF-8
len = %len(dataIn);
msg = 'lenIn*' + %char(len) + '*';
dsply msg;
dataOut = TEXT_runIconv(dataIn);
TEXT_closeIconv();
len = %len(dataOut);
msg = 'lenOut*' + %char(len) + '*';
dsply msg;
form = WEBFORM_open();
WEBFORM_setVar(form: 'chs': '200x200');
WEBFORM_setVar(form: 'cht': 'qr');
WEBFORM_setVar(form: 'chof': 'png');
WEBFORM_setPtr(form: 'chl': %addr(dataOut: *DATA):
%len(dataOut));
WEBFORM_postData(form: enc_data: enc_data_len);
rc = http_url_post ('[2]http://chart.apis.google.com/chart'
: enc_data
: enc_data_len
: '/jgvtmp/qr/' + artNumber + '.png');
WEBFORM_close(form);
return;
/end-free
I've seen in the GOOGLE-Documentation, that the input-string has to be
encoded in UTF-8, so I use iconv to do that. The result is a code, that
I can't read with my barcode-reader.
If I skip the conversion to UTF-8 and directly put the EBCDIC-String to
the webservice, I get a QR-Code, that I can read. But it is read as
http�www.xxxxxxx.ch-advanced?search?result.php_txtSearchArtnr^3970160
2
What am I doing wrong?
Best regards
Jan
References
1. http://www.xxxxxxx.ch/advanced_search_result.php
2. http://chart.apis.google.com/chart
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------