[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using HTTPAPI to generate QR-Codes



Hello Mike

Thank you very much. The integration of http_setCCSIDs( 1208: 0 ); didn't solve the problem. It seems that the conversion is done without this statement.

Best regards

Jan

Am 23.09.2014 um 18:59 schrieb Mike Krebs:
Jan,
CCSID problem caused by you doing your own conversion? Look at Scott's original program and you will see that he already had the conversion code in the program.

I think if you use the code as Scott wrote it, you should be fine even though you are on a different CCSID.
         // This configures HTTPAPI to use UTF-8 encoding
         //  (instead of plain ASCII):
         //

         http_setCCSIDs( 1208: 0 );

This will do the encoding from your job CCSID to UTF-8. Try that.

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Jan Grove Vejlstrup
Sent: Tuesday, September 23, 2014 9:07 AM
To: HTTPAPI and FTPAPI Projects
Subject: 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 =
'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 ('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^39701602





What am I doing wrong?

Best regards

Jan


-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------