which is the text associated with errno. This is V5R2. I am trying to do ebcdic to ascii translation. I would much appreciate any ideas anyone might have.

I prefer to use QtqIconvOpen(), I find that it's a little nicer than iconv_open(). Here's a sample of translating EBCDIC -> ASCII using that technique:

#include <qtqiconv.h>
#include <iconv.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

#define OUTBUFSIZE 32768

int main(int argc, char **argv) {

    QtqCode_T from, to;
    iconv_t ic;
    size_t insize, outleft;
    char outbuf[OUTBUFSIZE];
    char *inptr, *outptr;

    memset(&from, 0, sizeof(from));
    memset(&to, 0, sizeof(to));

    from.CCSID = 0;     // current job's EBCDIC
    to.CCSID   = 819;   // ISO 8859-1 ASCII

    ic = QtqIconvOpen(&to, &from);
    if (ic.return_value == -1) {
       fprintf(stderr, "QtqIconvOpen(): %s\n", strerror(errno));
       exit(1);
    }

    insize = strlen(argv[1]);
    inptr = argv[1];

    outleft = OUTBUFSIZE;
    outptr  = &outbuf[0];

    iconv(ic, &inptr, &insize, &outptr, &outleft);
    iconv_close(ic);

    printf("ASCII string = %s\n", outbuf);
    return 0;
}


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.