[英]How to convert a Simple Java String to EBCDIC with packed decimal format
i have to convert all the data in file to EBCDIC with packed decimal format. 我必须使用压缩十进制格式将文件中的所有数据转换为EBCDIC。
all the data in the file is in simple text format. 文件中的所有数据均为简单文本格式。
As per my knowledge we will need to convert the ASCII to EBCDIC Cp1047 or some other format first and then apply “packed decimal” logic/code.(may be i am wrong) 据我所知,我们将需要先将ASCII转换为EBCDIC Cp1047或其他某种格式,然后再应用“压缩十进制”逻辑/代码。(可能是我错了)
the converted format should be like "C3 C5 40 F0 C9 F8"(ie EBCDIC packed decimal format) 转换后的格式应类似于“ C3 C5 40 F0 C9 F8”(即EBCDIC打包的十进制格式)
Packed Decimal (Comp3 in Cobol) 打包十进制(Cobol中的Comp3)
Do you have a Cobol Copybook ???, if you do, see JRecord Question . 您是否有Cobol Copybook ???,如果有,请参阅JRecord Question 。 JRecord also has JRecord也有
Alternatives to JRecord are JRecord的替代品是
Note: I am the author of JRecord 注意:我是JRecord的作者
Converting a number to Packed Decimal is pretty easy and there are a number of ways to do it 将数字转换为压缩十进制非常简单,并且有很多方法可以实现
one option is 一种选择是
Java Code to convert an integer to Packed-Decimal Java代码将整数转换为Packed-Decimal
String val = Integer.toString(Math.abs(value));
if (value < 0) {
val = val.substring(1) + "D"
} else {
val += "C";
}
byte[] bytes = (new BigInteger(val, BASE_16)).toByteArray();
How to convert unpacked decimal back to COMP-3? 如何将解压缩的十进制转换回COMP-3?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.