Page 1 of 1

Converting hex to char

Posted: Wed Jul 29, 2009 11:49 pm
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

Posted: Thu Jul 30, 2009 12:14 am
by ray.wurlod
BASIC Transformer, Iconv(string[1,2], "MX0C")

Posted: Thu Jul 30, 2009 12:48 am
by bonds
Anyway to do it in parallel 8.1?

Posted: Thu Jul 30, 2009 12:49 am
by ArndW
One can do it in PX, but not as easily. Take a look at this thread

Posted: Thu Jul 30, 2009 2:07 am
by Network_CIS
given link says its Premium content :(

is there any work around?

Posted: Thu Jul 30, 2009 2:36 am
by ArndW
No, no work around from me, since I believe that the site is valuable and that membership pays to keep it running.

Posted: Thu Jul 30, 2009 5:20 am
by chulett
Well, you could always flex your C++ muscles to create a more 'parallel' solution.

Posted: Thu Jul 30, 2009 4:24 pm
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.

Posted: Thu Jul 30, 2009 6:50 pm
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;

Posted: Sun Aug 02, 2009 11:50 pm
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

Posted: Tue Aug 11, 2009 2:33 am
by marbis
hi

Posted: Tue Aug 11, 2009 2:34 am
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

Posted: Tue Aug 11, 2009 5:18 am
by chulett
Marbis, please start your own post on this subject.

Converting hex to char

Posted: Thu Aug 13, 2009 10:10 am
by marbis
hi,
i convert the hexadecimal value 0D0A to charapter with the constant X'0D0A'.

Bye

Posted: Thu Aug 13, 2009 4:57 pm
by ray.wurlod
Carriage return line feed?

You probably did not need to convert those explicitly at all.