PDA

View Full Version : Viewing in different formats


mohgdeisat
11th November 2006, 10:44 AM
Hi,

I am trying to create some kind of a viewer that can view files in different formats like:
Text(ASCII), Text(UNICODE),Bin, Hex, Oct.

the last two require dealing with bits, (3bits --> 1 oct), (4bits-->1 hex), so what is the fastest way to do this? I need to boost performance

Thanks

Mohammad

levenum
11th November 2006, 07:12 PM
Well, I am not sure about octal, but there is nothing easier or more "user friendly" than hex.

For example:


CString msg;
BYTE arrayOfByte[3];

msg.Format(_T("0x%02x 0x%02x 0x%02x"), arrayOfByte[0], arrayOfByte[1], arrayOfByte[2]);

MessageBox(msg, _T("Hex string"));


There are several operators in C++ language to deal with bits. For one thing you can use masks and binary operators to determine values of individual bits.

Any programming book will have a whole chapter dedicated to bit operations.

mohgdeisat
11th November 2006, 09:58 PM
Yes friend,

I know the basics of bitwise operators, I have been programming C++ for more than 5 years, but I just wonder if there is someway that is significantly faster than the usual way :)

Thanks

Mohammad