[Tutor] binary data as string?

Alan Gauld alan.gauld at blueyonder.co.uk
Sat Apr 17 04:01:13 EDT 2004


> Why not shift data and reverse the result?

Personal preference, I don't like modifying original 
data and since shifting is destructive (you lose the 
bits) you need to take a copy of the data before 
modifying it.

> That seemed to be the more general approach to me.
> > 
> > mask = 128    # = 1000000
> 
> If it is guarateed, that the Data unit is 8 bits.

In this case we were discussing characters so 8 bits 
is probably right (assuming UTF8 encoding).
The approach is general however, you just change the 
mask value to whatever size you need...

Alan G.





More information about the Tutor mailing list