Home  Contents

string.byterevert

String Core4 Lua Commands

SYNOPSIS

result = string.byterevert(s [, i [, j]])

DESCRIPTION

Reverses the order of bits in each byte of the string. The order of bytes in the string is not changed.

When i and/or j are given, uses the substring s[i], s[i+1], ···, s[j].
The default value for i is 1; the default value for j is the number of characters in s.

RETURN VALUE

A string with the bits of each byte reversed. The result has the same length as the original substring.

EXAMPLE

>  >  > 
foo = "\x03\x00" bar = foo:byterevert() print (foo:tohex(), bar:tohex())
0300 C000

SEE ALSO