vininet
vininet

Reputation: 21

How to change HEX value to EBCDIC char

What is the simplest way to convert HEX value to ebcdic char type in Java

e.g. The example below will return at sign but I would like to get ebcidic equivalent i.e. space char..

String hex = "40"; char c = (char) Integer.parseInt(hex, 16);

Upvotes: 2

Views: 6356

Answers (2)

Roee Feingold
Roee Feingold

Reputation: 11

To convert hex char to ebcdic (example: C1)

byte b[] = {(byte) Integer.parseInt("C1", 16)};
System.out.print(new String(b, "Cp037"));

The result will be A

Upvotes: 1

aioobe
aioobe

Reputation: 421060

Simples and most efficient solution would probably be to write up a lookup-table yourself, based on for instance http://www.natural-innovations.com/computing/asciiebcdic.html.

Other solutions can be found here.

Upvotes: 1

Related Questions