使用JAVA的EBCDIC到ASCII的转换 [英] EBCDIC to ASCII conversion using JAVA

查看:552
本文介绍了使用JAVA的EBCDIC到ASCII的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将主机固定长度文件从 EBCDIC 格式转换为 ASCII 格式.目前,我正在使用 JZOS api (ZFile)读取文件,并逐字段进行转换.仅读取记录或行的整个字节,是否可能在不知道文件布局(又名COPYBOOK)的情况下进行转换?如果是这样,如何处理压缩的小数和二进制值?

I'm trying to convert mainframe fixed length file from EBCDIC format to ASCII format. Currently I'm reading file using JZOS api (ZFile) and converting field by field. is it possible to convert without knowing the layout of file (aka COPYBOOK) by just reading entire bytes of a record or line? If so how do handle packed decimals and binary values?

推荐答案

是否可以在不知道文件布局的情况下进行转换(又名 只是读取记录或行的整个字节?

is it possible to convert without knowing the layout of file (aka COPYBOOK) by just reading entire bytes of a record or line?

否.

文本字段必须从EBCDIC转换为ASCII.必须转换二进制和压缩十进制字段 .如果转换二进制字段,则将更改它们的值,有可能(可能?确定吗?)您将破坏它们的值.

Text fields must be converted from EBCDIC to ASCII. Binary and packed decimal fields must not be converted. If you convert binary fields then you will alter their values, it's possible (likely? certain?) you will destroy their values.

来自大型机的二进制字段将是big-endian,您可能需要将它们转换为little-endian.在大型机中,半字中的+10为x'000A',而在小型字节序计算机上为x'0A00'.

Binary fields coming from a mainframe will be big-endian, you may need to convert these to little endian. +10 in a halfword on a mainframe is x'000A' while on a little endian machine it is x'0A00'.

压缩的十进制字段可能具有隐含的十进制位置.如果您的文件包含x'12345C',它可能表示+123.45或+12,345.字段的格式告诉您如何解释数据.

Packed decimal fields may have implied decimal positions. If your file contains x'12345C' that may represent +123.45 or +12,345. The format of the field tells you how to interpret the data.

如果不知道记录格式(包括字段格式),就无法进行转换.

You cannot do the conversion without knowing the record layout including field formats.

以我的经验,避免这些困难的最佳方法是对大型机上的文件进行预处理,将所有二进制和压缩的十进制字段转换为带有嵌入式显式符号和小数点的文本.然后,文件可以安全地通过代码页(在这种情况下为EBCDIC到ASCII)转换.

In my experience, the best way to avoid these difficulties is to preprocess the file on the mainframe, converting all binary and packed decimal fields to text with embedded explicit signs and decimal points. Then the file can safely go through code page (EBCDIC to ASCII in this case) conversion.

使用大型机SORT实用程序可以轻松完成这种预处理,该实用程序通常擅长数据转换.

Such preprocessing can easily be done with the mainframe SORT utility, which typically excel at data transformations.

这篇关于使用JAVA的EBCDIC到ASCII的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆