Daniel Richard G. dixit:

>It wouldn't work to do the EBCDIC->ASCII conversion all at runtime? z/OS
>does provide functions for this, and these will adjust to whatever the
>current EBCDIC codepage is:
>
>    etoa():
>    
> https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/r0ceta.htm
>
>    etoa_l():
>    
> https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/r0etal.htm

[…]

>Probably easier just to use etoa(), or atoe()?  I don't think explicit
>hand-edited tables should be needed for EBCDIC, unless you're already

Well, the hand-edited tables would be known to be stable and (somewhat)
correct, but…

>Even if you really do need a table, you could populate it on startup
>using these.

I guess I can probably work with that.

So we’re up for testing again!

#include <err.h>
#include <stdio.h>
#include <unistd.h>
int main(void) {
        int i = 256;
        char buf[256];
        while (i--)
                buf[i] = i;
        if ((i = __etoa_l(buf, 256)) != 256)
                err(1, "etoa_l: %d != 256", i);
        i = 0;
        while (i < 256) {
                printf(" %02X", (unsigned int)(unsigned char)buf[i]);
                if (!(++i & 15))
                        printf("\n");
        }
        return (0);
}

Can you run this in both codepages, and possibly their Euro equivalents?

There’s no EBCDIC to Unicode function (ideal would be something that
gets a char and returns an int or something, not on buffers) though,
is there? (If there is, runs of that would also be welcome.) I don’t
find one in the IBM library reference, and I had a look at z/OS Unicode
Services but… there’s CUNLCNV, but it looks extremely… IBM. So maybe
we can or have to make do with etoa and its limitations… probably
still enough at this point.

Thanks,
//mirabilos
-- 
[16:04:33] bkix: "veni vidi violini"
[16:04:45] bkix: "ich kam, sah und vergeigte"...

Reply via email to