What is the simplest way in C to convert an EBCDIC-encoded string to its ASCII equivalent in-place.
The only characters that need to be converted are the space, alphanumerics, and from the set <=>()+-*/&|!$#@.,;%_?". All other characters can simply be replaced with ..
The function signature will basically be:
void ebcdicToAscii (char *s);
At the moment, I'm leaning towards a series of lookup tables and multiple if statements for the various EBCDIC sections, but I wonder if there's a better way.
Using the table from here, from the top of my head:
For your specific requirements, I would suggest something like:
which outputs
Hello there!from the equivalent EBCDIC characters. All other characters beyond those you showed an interest in are converted to a space, though you can change that to something else (make sure you don't modify EBCDIC code0x40which is the real space).