Question : How to change HEX value to EBCDIC char

I need an example of java method that will be able to convert HEX value to ebcdic char type

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);

Answer : How to change HEX value to EBCDIC char

Now you're gona laugh when you see this, but actually it might be useful, especially if you seek to translate text.

See code attachment.

(You may need to use the Integer.parseInt(hex, 16) to get hex.)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
String ebcdicOfHex(char hexbyte) {
    String ebcdic = null;
    switch(hexbyte) {
        case 0x00: ebcdic = "<NUL>"; break;
        case 0x01: ebcdic = "<SOH>"; break;
        case 0x02: ebcdic = "<STX>"; break;
        case 0x03: ebcdic = "<ETX>"; break;
        case 0x04: ebcdic = "<SEL>"; break;
        case 0x05: ebcdic = "<HT>" ; break;
        case 0x06: ebcdic = "<RNL>"; break;
        case 0x07: ebcdic = "<DEL>"; break;
        case 0x08: ebcdic = "<GE>" ; break;
        case 0x09: ebcdic = "<SPS>"; break;
        case 0x0A: ebcdic = "<RPT>"; break;
        case 0x0B: ebcdic = "<VT>" ; break;
        case 0x0C: ebcdic = "<FF>" ; break;
        case 0x0D: ebcdic = "\r"; break;
        case 0x0E: ebcdic = "<SO>" ; break;
        case 0x0F: ebcdic = "<SI>" ; break;
        case 0x10: ebcdic = "<DLE>"; break;
        case 0x11: ebcdic = "<DC1>"; break;
        case 0x12: ebcdic = "<DC2>"; break;
        case 0x13: ebcdic = "<DC3>"; break;
        case 0x14: ebcdic = "<RES/ENP>"; break;
        case 0x15: ebcdic = "\n" ; break;
        case 0x16: ebcdic = "<BS>" ; break;
        case 0x17: ebcdic = "<POC>"; break;
        case 0x18: ebcdic = "<CAN>"; break;
        case 0x19: ebcdic = "<EM>" ; break;
        case 0x1A: ebcdic = "<UBS>"; break;
        case 0x1B: ebcdic = "<CU1>"; break;
        case 0x1C: ebcdic = "<IFS>"; break;
        case 0x1D: ebcdic = "<IGS>" ; break;
        case 0x1E: ebcdic = "<IRS>"; break;
        case 0x1F: ebcdic = "<ITB/IUS>"; break;
        case 0x20: ebcdic = "<DS>" ; break;
        case 0x21: ebcdic = "<SOS>"; break;
        case 0x22: ebcdic = "<FS>" ; break;
        case 0x23: ebcdic = "<WUS>"; break;
        case 0x24: ebcdic = "<BYP/INP>"; break;
        case 0x25: ebcdic = "<LF>" ; break;
        case 0x26: ebcdic = "<ETB>"; break;
        case 0x27: ebcdic = "<ESC>"; break;
        case 0x28: ebcdic = "<SA>" ; break;
        case 0x29: ebcdic = "<SFE>"; break;
        case 0x2A: ebcdic = "<SM/SW>"; break;
        case 0x2B: ebcdic = "<CSP>"; break;
        case 0x2C: ebcdic = "<MFA>"; break;
        case 0x2D: ebcdic = "<ENQ>"; break;
        case 0x2E: ebcdic = "<ACK>"; break;
        case 0x2F: ebcdic = "<BEL>"; break;
        case 0x30: break;
        case 0x31: break;
        case 0x32: ebcdic = "<SYN>"; break;
        case 0x33: ebcdic = "<IR>" ; break;
        case 0x34: ebcdic = "<PP>" ; break;
        case 0x35: ebcdic = "<TRN>"; break;
        case 0x36: ebcdic = "<NBS>"; break;
        case 0x37: ebcdic = "<EOT>"; break;
        case 0x38: ebcdic = "<SBS>"; break;
        case 0x39: ebcdic = "<IT>" ; break;
        case 0x3A: ebcdic = "<RFF>"; break;
        case 0x3B: ebcdic = "<CU3>"; break;
        case 0x3C: ebcdic = "<DC4>"; break;
        case 0x3D: ebcdic = "<NAK>"; break;
        case 0x3E: break;
        case 0x3F: ebcdic = "<SUB>"; break;
        case 0x40: ebcdic = " " ; break;
        case 0x41: ebcdic = "<RSP>"; break;
        case 0x42: break;
        case 0x43: break;
        case 0x44: break;
        case 0x45: break;
        case 0x46: break;
        case 0x47: break;
        case 0x48: break;
        case 0x49: break;
        case 0x4A: ebcdic = "["; break;
        case 0x4B: ebcdic = "."; break;
        case 0x4C: ebcdic = "<"; break;
        case 0x4D: ebcdic = "("; break;
        case 0x4E: ebcdic = "+"; break;
        case 0x4F: ebcdic = "|"; break;
        case 0x50: ebcdic = "&"; break;
        case 0x51: break;
        case 0x52: break;
        case 0x53: break;
        case 0x54: break;
        case 0x55: break;
        case 0x56: break;
        case 0x57: break;
        case 0x58: break;
        case 0x59: break;
        case 0x5A: ebcdic = "!"; break;
        case 0x5B: ebcdic = "$"; break;
        case 0x5C: ebcdic = "*"; break;
        case 0x5D: ebcdic = ")"; break;
        case 0x5E: ebcdic = ";"; break;
        case 0x5F: ebcdic = "^"; break;
        case 0x60: ebcdic = "_"; break;
        case 0x61: ebcdic = "/"; break;
        case 0x62: break;
        case 0x63: break;
        case 0x64: break;
        case 0x65: break;
        case 0x66: break;
        case 0x67: break;
        case 0x68: break;
        case 0x69: break;
        case 0x6A: ebcdic = "|"; break;
        case 0x6B: ebcdic = ","; break;
        case 0x6C: ebcdic = "%"; break;
        case 0x6D: ebcdic = "_"; break;
        case 0x6E: ebcdic = ">"; break;
        case 0x6F: ebcdic = "?"; break;
        case 0x70: break;
        case 0x71: break;
        case 0x72: break;
        case 0x73: break;
        case 0x74: break;
        case 0x75: break;
        case 0x76: break;
        case 0x77: break;
        case 0x78: break;
        case 0x79: ebcdic = "`"; break;
        case 0x7A: ebcdic = ":"; break;
        case 0x7B: ebcdic = "#"; break;
        case 0x7C: ebcdic = "@"; break;
        case 0x7D: ebcdic = "\""; break;
        case 0x7E: ebcdic = "="; break;
        case 0x7F: ebcdic = "\""; break;
        case 0x80: break;
        case 0x81: ebcdic = "a"; break;
        case 0x82: ebcdic = "b"; break;
        case 0x83: ebcdic = "c"; break;
        case 0x84: ebcdic = "d"; break;
        case 0x85: ebcdic = "e"; break;
        case 0x86: ebcdic = "f"; break;
        case 0x87: ebcdic = "g"; break;
        case 0x88: ebcdic = "h"; break;
        case 0x89: ebcdic = "i"; break;
        case 0x8A: break;
        case 0x8B: ebcdic = "{"; break;
        case 0x8C: break;
        case 0x8D: break;
        case 0x8E: break;
        case 0x8F: ebcdic = "+"; break;
        case 0x90: break;
        case 0x91: ebcdic = "j"; break;
        case 0x92: ebcdic = "k"; break;
        case 0x93: ebcdic = "l"; break;
        case 0x94: ebcdic = "m"; break;
        case 0x95: ebcdic = "n"; break;
        case 0x96: ebcdic = "o"; break;
        case 0x97: ebcdic = "p"; break;
        case 0x98: ebcdic = "q"; break;
        case 0x99: ebcdic = "r"; break;
        case 0x9A: break;
        case 0x9B: ebcdic = "}"; break;
        case 0x9C: break;
        case 0x9D: break;
        case 0x9E: break;
        case 0x9F: break;
        case 0xA0: break;
        case 0xA1: ebcdic = "~"; break;
        case 0xA2: ebcdic = "s"; break;
        case 0xA3: ebcdic = "t"; break;
        case 0xA4: ebcdic = "u"; break;
        case 0xA5: ebcdic = "v"; break;
        case 0xA6: ebcdic = "w"; break;
        case 0xA7: ebcdic = "x"; break;
        case 0xA8: ebcdic = "y"; break;
        case 0xA9: ebcdic = "z"; break;
        case 0xAA: break;
        case 0xAB: break;
        case 0xAC: break;
        case 0xAD: ebcdic = "["; break;
        case 0xAE: break;
        case 0xAF: break;
        case 0xB0: break;
        case 0xB1: break;
        case 0xB2: break;
        case 0xB3: break;
        case 0xB4: break;
        case 0xB5: break;
        case 0xB6: break;
        case 0xB7: break;
        case 0xB8: break;
        case 0xB9: break;
        case 0xBA: break;
        case 0xBB: break;
        case 0xBC: break;
        case 0xBD: break;
        case 0xBE: break;
        case 0xBF: break;
        case 0xC0: ebcdic = "{"; break;
        case 0xC1: ebcdic = "A"; break;
        case 0xC2: ebcdic = "B"; break;
        case 0xC3: ebcdic = "C"; break;
        case 0xC4: ebcdic = "D"; break;
        case 0xC5: ebcdic = "E"; break;
        case 0xC6: ebcdic = "F"; break;
        case 0xC7: ebcdic = "G"; break;
        case 0xC8: ebcdic = "H"; break;
        case 0xC9: ebcdic = "I"; break;
        case 0xCA: break;
        case 0xCB: break;
        case 0xCC: break;
        case 0xCD: break;
        case 0xCE: break;
        case 0xCF: break;
        case 0xD0: ebcdic = "}"; break;
        case 0xD1: ebcdic = "J"; break;
        case 0xD2: ebcdic = "K"; break;
        case 0xD3: ebcdic = "L"; break;
        case 0xD4: ebcdic = "M"; break;
        case 0xD5: ebcdic = "N"; break;
        case 0xD6: ebcdic = "O"; break;
        case 0xD7: ebcdic = "P"; break;
        case 0xD8: ebcdic = "Q"; break;
        case 0xD9: ebcdic = "R"; break;
        case 0xDA: break;
        case 0xDB: break;
        case 0xDC: break;
        case 0xDD: break;
        case 0xDE: break;
        case 0xDF: break;
        case 0xE0: ebcdic = "\\"; break;
        case 0xE1: break;
        case 0xE2: ebcdic = "S"; break;
        case 0xE3: ebcdic = "T"; break;
        case 0xE4: ebcdic = "U"; break;
        case 0xE5: ebcdic = "V"; break;
        case 0xE6: ebcdic = "W"; break;
        case 0xE7: ebcdic = "X"; break;
        case 0xE8: ebcdic = "Y"; break;
        case 0xE9: ebcdic = "Z"; break;
        case 0xEA: break;
        case 0xEB: break;
        case 0xEC: break;
        case 0xED: break;
        case 0xEE: break;
        case 0xEF: break;
        case 0xF0: ebcdic = "0"; break;
        case 0xF1: ebcdic = "1"; break;
        case 0xF2: ebcdic = "2"; break;
        case 0xF3: ebcdic = "3"; break;
        case 0xF4: ebcdic = "4"; break;
        case 0xF5: ebcdic = "5"; break;
        case 0xF6: ebcdic = "6"; break;
        case 0xF7: ebcdic = "7"; break;
        case 0xF8: ebcdic = "8"; break;
        case 0xF9: ebcdic = "9"; break;
        case 0xFA: break;
        case 0xFB: break;
        case 0xFC: break;
        case 0xFD: break;
        case 0xFE: break;
        case 0xFF: break;
        default : ebcdic = "<<UNHANDLED CODE>>"; break;
    }
    return ebcdic;
}
Random Solutions  
 
programming4us programming4us