简体   繁体   English

无法将小写字母从 EBCDIC 转换为 ASCII

[英]No able to convert Lowercase Letters from EBCDIC to ASCII

I have written the code to convert the data from EBCDIC to ASCII which is working fine for digits and Uppercase letters such as 1, 2, A, B, C.我已经编写了将数据从 EBCDIC 转换为 ASCII 的代码,该代码适用于数字和大写字母,例如 1、2、A、B、C。 However, it not converting lowercase letters l and when are printing them in the logs it prints non readable characters.但是,它不会转换小写字母 l 并且当在日志中打印它们时会打印不可读的字符。 Below is the code snipped that we are using for conversion.下面是我们用于转换的代码片段。

 public String ebcdicToAscii(String ebcdicValue) {
    String asciiBuffer = null;
    logger.debug("converting field value frm ebcdic to Ascii. ");
    try {

      byte[] ebcdicByteArr = ebcdicValue.toString().getBytes(StandardCharsets.ISO_8859_1);
      int textLen = ebcdicByteArr.length;
      AS400Text textConverter = new AS400Text(textLen);
      asciiBuffer = ((String) textConverter.toObject(ebcdicByteArr)).substring(0, textLen);
      System.out.println("value: "+asciiBuffer);
    } catch (Exception e) {
      logger.error("error while converting field value from ebcdic To Ascii:  " + e);
    }
    return asciiBuffer;
  }

Could anyone please help me fixing this issue.谁能帮我解决这个问题。

ok...if the problem is only with lower letters then:好的...如果问题只是小写字母,那么:

  1. convert lowercase letters to uppercase将小写字母转换为大写
    UpperCase = ebcdicValue.toUpperCase();
  1. convert EBCDIC to ASCII将 EBCDIC 转换为 ASCII

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM