[EMAIL PROTECTED] wrote:

> Somebody asked me about generating UTF-32 (he didn't have choice of the
> output format).  I was about to propose the obvious ``u.encode('utf-32')``
 > but discovered it's missing.

hint 1:

 >>> u = u"Hello"
 >>> a = array.array("I", map(ord, u))
 >>> a.tostring()
'H\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00'
 >>> a.byteswap()
 >>> a.tostring()
'\x00\x00\x00H\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o'

hint 2:

 >>> import sys
 >>> sys.byteorder
'little'

</F>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to