Click here to Skip to main content
14,300,487 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,

Is there any in built function in c to convert ascii value to ebcidic?

or we need to write the function our own?

What I have tried:

i can see some conversion functions but want to know is there any functions available
Posted
Updated 6-May-19 8:21am
Rate this:
Please Sign up or sign in to vote.

Solution 1

There is an IBM function to do it: (string) IBM Knowledge Center[^], (chars) IBM Knowledge Center[^] But they will require non-standard IBM libraries which you probably won't have access to. Which makes sense, since about the only people who ever used EBCDIC was IBM ... :laugh:

To be honest, it's a pretty trivial conversion: two arrays of 255 characters, one organised by ASCII index, the other by EBCDIC would do it very simply: IBM Knowledge Center[^]

But I'm fascinated to know what the heck equipment is still running that uses EBCDIC anyway? :D
   
Comments
Member 14161770 6-May-19 3:20am
   
Our host runs on IBM mainframe, which need data in the same format :P
OriginalGriff 6-May-19 3:25am
   
Good grief. Does it still accept punch cards? :laugh:
Gerry Schmitz 6-May-19 15:18pm
   
The IBM virtual machines have virtual card readers. And punches. I know one big company that has been for years. They just keep "copying" stuff any time a new division is created (at least once a year it seems).
OriginalGriff 6-May-19 15:36pm
   
That'll be for the COBOL code they can't get away from? :laugh:
Rate this:
Please Sign up or sign in to vote.

Solution 4

A strategy for you - an alternative to a function - maybe just for thinking about - but maybe what you need.

Create a 256 byte array. Assume the array index is the ASCII value of your source character. Set the value of each to the EBCDIC value. Now, instead of a function call you can transcribe the array by looping through the input as ASCII values and writing the value assigned to that index to your new string.

Ultimately, any way you do this, each character will need to be addressed - this skips the overhead of a function call band instead uses a lookup list - which are ordinarily very fast.
   
v2
Comments
0x01AA 6-May-19 15:08pm
   
Why a function which translates a string is that bad? And sorry keep in mind DRY. No vote from my side, even if this would have earned something between 1 and 3!
W Balboos 6-May-19 15:12pm
   
Neither is bad - but the if this were done a lot, each function call would have overhead such as pushing and popping stack values. Now if this is compiled, the function could possibly be inlined and do this anyway.

It just saves overhead but requires you code a loop instead of a function call with an input and returned value.

Internally, one way or another, you'd be using the lookup table concept in a function.
0x01AA 6-May-19 15:16pm
   
"Internally, one way or another, you'd be using the lookup table concept in a function": I agree. Ok a 4 :(
W Balboos 6-May-19 15:23pm
   
Thanks. I'm rather old-school and used to do various numerical modeling applications. Often, an "call" would happen tens of millions of times. That really adds up with functions vs. inline. Remember, too, how much slower CPUs were. So - the habit sort of sticks - doesn't cause any harm if it's a one-time event.

Think of a pecking order of efficiency:
Direct inline conversion
Function-conversion via by input strings
Function-conversion, a character at a time.

The last, obviously extreme, emphasizes the point - although I'm quite sure you already have it. Someday, you may even need it.
0x01AA 6-May-19 15:33pm
   
"I'm rather old-school": Same here :)
Rate this:
Please Sign up or sign in to vote.

Solution 3

Quote:
Is there any in built function in c to convert ascii value to ebcidic?

Short answer: No
Quote:
or we need to write the function our own?

Short answer: Yes

If you have a problem on your function, show code and explain problem to get help.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100