Converting the Ascii string to Hexadecimal
Last Post 17 Jan 2013 12:12 PM by Bryan Leaman. 3 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Eli
New Member
New Member
Posts:54

--
16 Jan 2013 11:22 AM

Hello

I have the question about the way to convert the ascii string to the hexadecimal ( or character representation ).

First of all the I think it's important to explain the beginning of story :

1. The IFS stream file had been journaled

2. After some data changed in this file the captured data changes via DSPJRN command had been captured to output file

3. In one of this file fields - JOESD - this IFS file changed data are logged  in ASCII 

... and I have the task to convert it ot EBCDIC -

Does anybody knows the appropriate solution ?

 

Eli

Jim Suiter
Veteran Member
Veteran Member
Posts:1565
Avatar

--
16 Jan 2013 01:18 PM

check out these MI procedures:

 *-------------------------------------------------------------------------
D ToHex           PR                  EXTPROC('cvthc')                     
D  szHexVal                  65534A   OPTIONS(*VARSIZE)                    
D  szCharVal                 32767A   Const OPTIONS(*VARSIZE)              
D  nSrcLen                      10I 0 VALUE                                
 *-------------------------------------------------------------------------
D FromHex         PR                  EXTPROC('cvtch')                     
D  szCharVal                 32767A   OPTIONS(*VARSIZE)                    
D  szHexVal                  65534A   Const OPTIONS(*VARSIZE)              
D  nSrcLen                      10I 0 VALUE                                
 *-------------------------------------------------------------------------

 

Barbara Morris
Senior Member
Senior Member
Posts:5199

--
16 Jan 2013 02:57 PM
Posted By Eli on 16 Jan 2013 12:22 PM

Hello

I have the question about the way to convert the ascii string to the hexadecimal ( or character representation ).

...

3. In one of this file fields - JOESD - this IFS file changed data are logged  in ASCII 

... and I have the task to convert it ot EBCDIC -


Eli, can you clarify exactly what you want to do? I'm confused by the "hexadecimal" part.

If you have ASCII data and want to convert it to EBCDIC, then the iconv() API will do that. If you google for iconv rpg then you should find some good examples.

Bryan Leaman
Veteran Member
Veteran Member
Posts:1745
Avatar

--
17 Jan 2013 12:12 PM
Regarding point 3 -- I'm going to take a shot-in-the-dark and point out that you've probably go binary data in JOESD. (I haven't dealt with journaling IFS files much.) If you're guaranteed that your IFS files are always ASCII (ccsid 819) then maybe you could do a simple ascii-ebcdic conversion, but I'm going to guess that you'll want the iconv routine and be able to handle other ccsid's at some point. Keep in mind that an IFS file could be any number of ccsid's, including unicode, and could be changed from one to another. So you may not be able to count on having EBCDIC characters for everything in the files.

--Bryan

P.S. iconv isn't the simplest API to understand and get working properly (though it's not the toughest either!). If you have a specific issue getting iconv working, post again!
You are not authorized to post a reply.

Acceptable Use Policy