"convert" string to bytes without changing data (encoding)
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Mar 28 14:12:57 EDT 2012
On Wed, 28 Mar 2012 11:43:52 +0200, Peter Daum wrote:
> ... in my example, the variable s points to a "string", i.e. a series of
> bytes, (0x61,0x62 ...) interpreted as ascii/unicode characters.
No. Strings are not sequences of bytes (except in the trivial sense that
everything in computer memory is made of bytes). They are sequences of
CODE POINTS. (Roughly speaking, code points are *almost* but not quite
the same as characters.)
I suggest that you need to reset your understanding of strings and bytes.
I suggest you start by reading this:
http://www.joelonsoftware.com/articles/Unicode.html
Then come back and try to explain what actual problem you are trying to
solve.
--
Steven
More information about the Python-list
mailing list