Skip to content

Commit

Permalink
bugfix in asciiToEbcdic(byte[] s, byte[] e, int offset)
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Aug 31, 2016
1 parent 1ac7934 commit 8a12c18
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jpos/src/main/java/org/jpos/iso/ISOUtil.java
Expand Up @@ -248,7 +248,7 @@ public static void asciiToEbcdic(String s, byte[] e, int offset) {
public static void asciiToEbcdic(byte[] s, byte[] e, int offset) {
int len = s.length;
for (int i=0; i<len; i++)
e[offset + i] = ASCII2EBCDIC[s[i]];
e[offset + i] = ASCII2EBCDIC[s[i]&0xFF];
}

/**
Expand Down

5 comments on commit 8a12c18

@alcarraz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering why, being s[i] a byte s[i]&0xFF isn't the same as s[i]

@ar
Copy link
Member Author

@ar ar commented on 8a12c18 Aug 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s[i] can give you an int that can be negative. The &0xFF fixes that.

@demsey
Copy link
Contributor

@demsey demsey commented on 8a12c18 Sep 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, I do not understand why jPOS maintains 2 arrays ISOUtil.EBCDIC2ASCII and ISOUtil.ASCII2EBCDIC (exposed as public) when they can be populated at runtime as codes of Charset.forName("IBM1047") (aka EBCDIC)
Some time ago i have checked that this encoding produces exacly same byte codes.

@vsalaman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demsey, legacy reasons... That code is from 1999.

@ar
Copy link
Member Author

@ar ar commented on 8a12c18 Sep 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @vsalaman said, legacy reasons, but a PR is Welcome to get that code better (provided is not slower than what we have now, which is pretty fast). Endpoints using EBCDIC happen to be high load legacy institutions and I wouldn't like to slow the code down.

Please sign in to comment.