Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am using perl on a native EBCDIC platform (z/OS). I need to write UTF-8 data to a file, and I do mean UTF-8 and NOT UTF-EBCDIC. When I use the ':utf8' directive on the file open command, I find that perl uses UTF-EBCDIC, so the written file is NOT UTF-8. What should I do to write real UTF-8 data to a file? Any help is highly appreciated.
  • Comment on How to write true utf8 data to a file on native ebcdic system?

Replies are listed 'Best First'.
Re: How to write true utf8 data to a file on native ebcdic system?
by moritz (Cardinal) on Mar 19, 2011 at 20:17 UTC
Re: How to write true utf8 data to a file on native ebcdic system?
by repellent (Priest) on Mar 19, 2011 at 20:59 UTC
    Try :encoding(UTF-8) instead of :utf8.
Re: How to write true utf8 data to a file on native ebcdic system?
by Illuminatus (Curate) on Mar 19, 2011 at 20:09 UTC
    z/OS?!? you poor b*st*rd...

    It looks like, from what I have read, that :utf8 means :utf-ebcdic on ebcdic-based systems. Are you really using all 8-bits? It looks like :ascii ought to work, but obviously won't give you chars with the high-bit set. Otherwise, you might have to do the encoding before the writing. See p13 here, assuming you have not already read this.

    fnord

Re: How to write true utf8 data to a file on native ebcdic system?
by Anonymous Monk on Mar 19, 2011 at 22:56 UTC
    //PASTLIFE JOB (FROM,HELL),'BUT IT PAYS WELL'
    //STEP1 EXEC PGM=PERL


    Ick ...
Re: How to write true utf8 data to a file on native ebcdic system?
by huzeh00 (Initiate) on Mar 21, 2011 at 18:52 UTC
    Thanks for your suggestions to my question (this node was entered by me, I made a registration, but found later that my question was registered as coming from anonymous). However, though the documentation suggests that from 5.8.7 onward (and my z/OS-USS perl version is 5.8.7) UTF-8 would be truly UTF-8 whereas utf8 might be platform dependent, it simply doesn't work. I tried different constructions using 'UTF-8' and even 'UTF-8-strict', with and without PerlIO. I keep ending up with UTF-EBCDIC output. I think I'll just have to write my own conversion function for this.