Page 1 of 1

Hex-Binary conversion

Posted: Fri Feb 06, 2009 8:55 pm
by edgore
I am working on a project that involves parsing some XML that includes file permission information that has been encoded using a bitmask. The bit mask has been converted into hexidecimal for inclusion in the xml files.

What I would like to be able to do is read the xml file and decode the hexidecimal into zeros and ones, from which I can then translate the flipped bits the file permissions.

I have been trying to figure out how to do this using the binarydecode function, but I think I am totally on the wrong track - it is converting the characters to binary, but since I can't figure out how to tell it that the input is hex it's spitting back the 8 bit's that represent the character rather than the 4 bits represented by the hex number that I want...

Is there a way to do this? I am obviously terrible at real computer stuff.

Posted: Sat Feb 07, 2009 12:08 am
by Mark
Dear edgore,

Please post the relevant part of your script.

Best,

Mark

Posted: Sun Feb 08, 2009 2:17 pm
by Mark Smith
As Mark suggests, it's often easier to give good answers when we can se the context, but baseconvert() may be your best bet here...

Code: Select all

put baseconvert(tHexString, 16, 2) into tBitString

If tHexString were 'fc1b', the output would be '1111110000011011'

Posted: Tue Feb 24, 2009 9:19 pm
by edgore
Sorry for the delay - I ended up just writing a dirty little switch routine that hand converted from hex to binary, since there were only 16 values to deal with.

I looks like baseconvert is what I was looking for though - I will rewrite to use that.

Thansk!