[Numpy-discussion] numpy uint16 array to unicode string

Janwillem jwevandijk@xs4all...
Sat Feb 25 14:32:47 CST 2012


Thanks, works, should have found that myself.

On 25-02-2012 20:56, Robert Kern wrote:
> On Sat, Feb 25, 2012 at 19:50, Janwillem<jwevandijk@xs4all.nl>  wrote:
>> I have a buffer as a numpy array of uint16. Chunks of this buffer are
>> unicode characters. How do I get these chunks, say data[start:end], in a
>> string?
> data[sart:end].tostring().decode('UTF-16LE')
>
> or 'UTF-16BE' if they are big-endian.
>
>> Other chunks are 32bit integers how do I get these chunks into a numpy
>> array of int32?
> data[start:end].view(np.int32)
>



More information about the NumPy-Discussion mailing list