Converting hex to char

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
bonds
Premium Member
Premium Member
Posts: 15
Joined: Thu Aug 16, 2007 12:34 am
Location: Australia

Converting hex to char

Post by bonds »

Hi,

Need to write to a flat file where first two characters of each record should be char version of a hexadecimal value. i.e. '4F44' is should show as 'OD' in output file.

Could you please suggest how to convert Hex value to Char

regards,
Satish
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

BASIC Transformer, Iconv(string[1,2], "MX0C")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bonds
Premium Member
Premium Member
Posts: 15
Joined: Thu Aug 16, 2007 12:34 am
Location: Australia

Post by bonds »

Anyway to do it in parallel 8.1?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

One can do it in PX, but not as easily. Take a look at this thread
Network_CIS
Premium Member
Premium Member
Posts: 12
Joined: Thu Jul 30, 2009 1:33 am
Location: Melbourne

Post by Network_CIS »

given link says its Premium content :(

is there any work around?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

No, no work around from me, since I believe that the site is valuable and that membership pays to keep it running.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well, you could always flex your C++ muscles to create a more 'parallel' solution.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can see the entirety of my entry (it's short enough not to be affected by the premium size cutoff) and it IS a parallel solution.
Last edited by ray.wurlod on Thu Jul 30, 2009 8:13 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Network_CIS
Premium Member
Premium Member
Posts: 12
Joined: Thu Jul 30, 2009 1:33 am
Location: Melbourne

Post by Network_CIS »

While my premium membership is still under review...
Found this solution in unix:

hexchar="FF"
octchar=$(echo "ibase=16;obase=8;$hexchar"|bc)
hexInChar=$(echo "\0$octchar")

Could you please suggest how to embed this code in DS job.

Via oracle char code could be found by:
select HEXTORAW(hex) as value from hextable;
bonds
Premium Member
Premium Member
Posts: 15
Joined: Thu Aug 16, 2007 12:34 am
Location: Australia

Post by bonds »

Thanks for all the suggestions.

Using server job was certainly a simple and good option; however, had issues with converting values like 8A, which are not standard ascii values. DS was generating '?' where unix was generating a wierd symbol sililar to 'g'

Workaround: running the unix script after the ds job to change hex to char codes
marbis
Participant
Posts: 5
Joined: Tue Jul 14, 2009 9:01 am

Post by marbis »

hi
Last edited by marbis on Tue Aug 11, 2009 2:36 am, edited 1 time in total.
marbis
Participant
Posts: 5
Joined: Tue Jul 14, 2009 9:01 am

Post by marbis »

Hi ,
i must convert exadecimal values in char values in main frame job.
The function ICONV doesn't exist.
Cai i do?
Is difficult?
Bye
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Marbis, please start your own post on this subject.
-craig

"You can never have too many knives" -- Logan Nine Fingers
marbis
Participant
Posts: 5
Joined: Tue Jul 14, 2009 9:01 am

Converting hex to char

Post by marbis »

hi,
i convert the hexadecimal value 0D0A to charapter with the constant X'0D0A'.

Bye
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Carriage return line feed?

You probably did not need to convert those explicitly at all.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply