The SWAP_ENDIAN function reverses the byte ordering of arbitrary scalars, arrays or structures. It can make "big endian" number "little endian" and vice-versa.
| Note |
This routine is written in the IDL language. Its source code can be found in the file swap_endian.pro in the lib subdirectory of the IDL distribution.
Result = SWAP_ENDIAN(Variable [, /SWAP_IF_BIG_ENDIAN] [, /SWAP_IF_LITTLE_ENDIAN])
SWAP_ENDIAN returns values of the same type and structure as the input value, with the pertinent bytes reversed.
The named variable-scalar, array, or structure-to be swapped.
If this keyword is set, the swap request will only be performed if the platform running IDL uses "big endian" byte ordering. On little endian machines, the SWAP_ENDIAN request quietly returns without doing anything. Note that this keyword does not refer to the byte ordering of the input data, but to the computer hardware.
If this keyword is set, the swap request will only be performed if the platform running IDL uses "little endian" byte ordering. On big endian machines, the SWAP_ENDIAN request quietly returns without doing anything. Note that this keyword does not refer to the byte ordering of the input data, but to the computer hardware.
; Reverse the byte order of A: A = SWAP_ENDIAN(A)
Introduced: Pre 4.0
SWAP_IF_BIG_ENDIAN and SWAP_IF_LITTLE_ENDIAN keywords added: 5.6
BYTEORDER, SWAP_ENDIAN_INPLACE