numpy uint16 array to unicode string
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? Other chunks are 32bit integers how do I get these chunks into a numpy array of int32? Many thanks, Janwillem
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) -- Robert Kern
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)
participants (2)
-
Janwillem -
Robert Kern