I stand corrected. It Is not that COBOL conversion from EBCDIC to UTF-8 isn't
possible using the intrinsic functions, but pretty much automatic conversion is
actually much, much simpler.
COBOL V6.4 supports DYNAMIC LENGTH UTF-8 elementary items, and all that is
necessary to convert an EBCDIC variable content to UTF-8 is the following:
WORKING-STORAGE SECTION.
01 UTF8-LEN PIC 9(4).
01 EBCDIC-ITEM PIC X(10) VALUE 'TEST UTF-8'.
01 UTF8-ITEM PIC U DYNAMIC LENGTH.
. . . .
PROCEDURE DIVISION.
MOVE EBCDIC-ITEM TO UTF8-ITEM
COMPUTE UTF8-LEN = FUNCTION LENGTH (UTF8-ITEM)
DISPLAY 'EBCDIC=' EBCDIC-ITEM
',UTF8LEN=' UTF8-LEN
',UTF8HEX=' FUNCTION HEX-OF (UTF8-ITEM)
I did not need to code to CALL Unicode Services as it appears the COBOL
environment is doing it for me. I do wish I had done more RTFM to start with,
but the exercise of making a Unicode Services call work from COBOL was
interesting and instructive, nonetheless.
The only caveat I see is that the compiler option CODEPAGE value (compiler
default is 1140 unless overridden at your installation) controls the source
code page for the "automatic" conversion, so to get conversion from 1047 to
UTF-8 (1208) you must compile with CODEPAGE(1047).
I learned this tidbit by reading the COBOL Programmer's Guide manual Chapter 7,
section "Using UTF-8 data (Unicode) in COBOL".
I do love learning something new each day (when possible), and this has
certainly been a fine day for me.
Thanks to all for the help you offered. I knew I could count on this list to
assist me.
Peter
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of
Farley, Peter
Sent: Sunday, December 14, 2025 3:59 PM
To: [email protected]
Subject: Re: z/OS Unicode Services: Can CUNLCNV be invoked dynamically?
Yes, I have looked at the intrinsic functions, but at least in the V6.4
documentation that I have in PDF form (Fourth edition (28 February 2023
update)) there are not any intrinsic functions to do character conversion that
I can see.
I will go get a more recent copy (we are on 6.4.0 P241021, so much later than
Feb. 2023) and look again. Thanks for the suggestion.
Peter
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of
Paul Feller
Sent: Sunday, December 14, 2025 2:29 PM
To: [email protected]
Subject: Re: z/OS Unicode Services: Can CUNLCNV be invoked dynamically?
I can't help with the issue you are seeing, but I do have a curious
question.
Have you looked at the intrinsic function support in COBOL to see if that
would be of any help with your character conversion?
Paul
--
This message and any attachments are intended only for the use of the addressee
and may contain information that is privileged and confidential. If the reader
of the message is not the intended recipient or an authorized representative of
the intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication
in error, please notify us immediately by e-mail and delete the message and any
attachments from your system.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN