We're in the process of updating our COBOL programs running on an IBM Mainframe (z/OS) to support non-latin characters.
I'm struggling a bit with understanding how COBOL processes UTF-16 characters defined as PIC N.
I need to update a field currently defined as PIC X to PIC N. This field then gets written to a file.
Example:
01 RecordToWrite PIC X(20).
I understand PIC N needs twice as much space as PIC X. What I don't know is how to define the corresponding PIC N field.
My guess would be COBOL takes care of the conversion itself:
01 RecordToWrite PIC N(20).
But I'm really not sure if it's that simple.
Can I just simply define the old field as PIC N without having to worry that my file still looks the same? Which measures do I need to take?
答案 0 :(得分:1)
你的领域:
01 RecordToWrite PIC N(20).
对于20个字符,将消耗40个字节。因此,您需要进行相应的调整,从X到N.
您可能还需要使用NATIONAL-OF和DISPLAY-OF函数将其转换为UTF-16或CCSID 1200.一旦转换了数据,您就不再需要使用它了,你的40字节/ 20字符Pic N的行为就像旧的Pic X字段一样 - 除非你必须与系统中未转换的部分交谈。