Re: [SLE] [Way OT] Does anyone know c callable API for converting from ascii to ebcdic?
Mads Martin Joergensen writes:
* Greg Freemyer <freemyer@NorcrossGroup.com> [May 30. 2002 19:35]:
Guys,
The subject speaks for itself.
i.e. Does anyone know C callable API for converting from ascii to ebcdic?
And I know "dd" can do this, but I need to be able to do it from C, or possibly Java.
I just need to be able to convert one char at a time, so I guess I can write my own easily enough once I find an ebcdic chart.
Look at the dd source perhaps?
And these questions should go to our new suse-programming-e list :)
Here is something that I have found. It uses a simple table lookup to convert an entire buffer. We also have a swedish to ebcdic as well. static unsigned char const latin1_to_ebcdicus[256] = { 0, 1, 2, 3, 4, 5, 6, 7, /* 0 - 7 */ 8, 9, 10, 11, 12, 13, 14, 15, /* 8 - 15 */ 16, 17, 18, 19, 20, 21, 22, 23, /* 16 - 23 */ 24, 25, 26, 27, 28, 29, 30, 31, /* 24 - 31 */ 64, 90, 127, 123, 91, 108, 80, 125, /* 32 - 39 */ 77, 93, 92, 78, 107, 96, 75, 97, /* 40 - 47 */ 240, 241, 242, 243, 244, 245, 246, 247, /* 48 - 55 */ 248, 249, 122, 94, 76, 126, 110, 111, /* 56 - 63 */ 124, 193, 194, 195, 196, 197, 198, 199, /* 64 - 71 */ 200, 201, 209, 210, 211, 212, 213, 214, /* 72 - 79 */ 215, 216, 217, 226, 227, 228, 229, 230, /* 80 - 87 */ 231, 232, 233, 36, 224, 41, 59, 109, /* 88 - 95 */ 121, 129, 130, 131, 132, 133, 134, 135, /* 96 - 103 */ 136, 137, 145, 146, 147, 148, 149, 150, /* 104 - 111 */ 151, 152, 153, 162, 163, 164, 165, 166, /* 112 - 119 */ 167, 168, 169, 192, 79, 208, 161, 255, /* 120 - 127 */ 128, 47, 98, 99, 100, 101, 102, 103, /* 128 - 135 */ 104, 105, 138, 139, 140, 141, 142, 143, /* 136 - 143 */ 144, 119, 44, 37, 172, 62, 63, 112, /* 144 - 151 */ 113, 114, 154, 155, 156, 157, 158, 159, /* 152 - 159 */ 160, 61, 74, 116, 117, 118, 106, 120, /* 160 - 167 */ 45, 58, 170, 171, 95, 173, 174, 175, /* 168 - 175 */ 176, 177, 178, 179, 180, 181, 182, 183, /* 176 - 183 */ 184, 185, 186, 187, 188, 189, 190, 191, /* 184 - 191 */ 35, 65, 66, 67, 68, 69, 70, 71, /* 192 - 199 */ 72, 73, 202, 203, 204, 205, 206, 207, /* 200 - 207 */ 39, 115, 46, 60, 40, 43, 32, 38, /* 208 - 215 */ 81, 82, 218, 219, 220, 221, 222, 223, /* 216 - 223 */ 42, 225, 83, 84, 85, 86, 87, 88, /* 224 - 231 */ 89, 33, 234, 235, 236, 237, 238, 239, /* 232 - 239 */ 48, 49, 50, 51, 52, 53, 54, 55, /* 240 - 247 */ 56, 57, 250, 251, 252, 253, 254, 34, /* 248 - 255 */ }; void us_ascii_to_ebcdic ( void *in, void *out, int len ) { unsigned char *src = (unsigned char *) in, *dst = (unsigned char *) out; for (; lgt > 0; lgt--) *dst++ = latin1_to_ebcdicus[(int) *src++]; }
participants (1)
-
Jesse Marlin