converting bytarr into strarr [message #44514] |
Tue, 21 June 2005 14:52 |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Hello there,
This is probably a simple question, but I haven't found out how to do it.
How does one convert a byte array into a equivalent sized string array? E.g. consider the
following:
IDL> a=bindgen(20,40)
IDL> help, a
A BYTE = Array[20, 40]
IDL> b=string(a)
IDL> help, b
B STRING = Array[40]
IDL>
or
IDL> a=bindgen(2,4,5,6)
IDL> help, a
A BYTE = Array[2, 4, 5, 6]
IDL> b=string(a)
IDL> help, b
B STRING = Array[4, 5, 6]
What I want to do is convert "a" into a string array, "b", that has the same dimensions as
the original byte array, [20, 40], or [2, 4, 5, 6] i.e. each element of "b" is a single
character corresponding to the byte value in "a".
Everything I've read in the IDL help tells me that a byte array will always "lose" the
first dimension as the bytes are converted into concatenated strings.
Is there a simple way around this? (I could loop over the dimensions of "a" I guess).
thanks,
paulv
--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
|
|
|