swap_endian
Builtin index · Collections & strings
swap_endian(bytes, [width=4])
Input: bytes, width · Output: no output
What it is
Reverses the byte order within each width-byte chunk (big-endian u32s become little-endian and back), unlike reverse_bytes, which reverses the whole buffer. The length must divide evenly by width; a partial trailing chunk is an error, not silently dropped. swap_endian([1, 2, 3, 4], width=2) is [2, 1, 4, 3].
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
swap_endian(bytes, [width=4]) | bytes —not documented yetwidth optional (default 4)Reverses the byte order within each width-byte chunk (big-endian u32s become little-endian and back), unlike reverse_bytes, which reverses the whole buffer. | not documented yet | — |
Examples
No documentation example calls this form yet. The Collections & strings chapter is where one belongs.