Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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
 
Share this answer
 
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:
[no name] 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:
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.
 
Share this answer
 
v2
Comments
[no name] 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, GHB 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.
[no name] 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, GHB 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.
[no name] 6-May-19 15:33pm    
"I'm rather old-school": Same here :)
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.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900