Converting UTF-8 to national (NATIONAL-OF)
You can use one of the two methods described in this topic to convert a UTF-8 data item to a national data item.
About this task
- When a UTF-8 item (USAGE UTF-8) is used as the sender and a national item is used as the
receiver, the
MOVEstatement converts automatically. Do not use theNATIONAL-OFintrinsic function.For example:01 UTF8-SEND PIC U(100). 01 NAT-RECV PIC N(100). ... MOVE "abcd" TO UTF8-SEND MOVE UTF8-SEND TO NAT-RECVUTF8-SENDcontains hex "61626364" padded by hex "20" (spaces). Upon execution of the lastMOVEstatement,NAT-RECVcontains hex "0061006200630064" padded by hex "0020" (spaces). - When UTF-8 data is stored in an alphanumeric item at runtime, use the
NATIONAL-OFintrinsic function to convert the data to a national item.For example:01 ALPHA-SEND PIC X(100). 01 NAT-RECV PIC N(100). ... MOVE X"61626364" TO ALPHA-SEND MOVE FUNCTION NATIONAL-OF(ALPHA-SEND(1:4) 1208) TO NAT-RECVALPHA-SEND(1:4) contains hex "61626364". Upon execution of the last
MOVEstatement,NAT-RECVcontains hex "0061006200630064" padded by hex "0020" (spaces).