- value = string.cvi(s [, i [, j]])
- value = string.cvin(s [, i [, j]])
- value = string.cvl(s [, i [, j]])
- value = string.cvln(s [, i [, j]])
SYNOPSIS
DESCRIPTION
The functions convert a substring into a binary value. All functions take a substring
s[i], s[i+1], ···, s[j] as input.
The
default value for i is 1; the default value for j is the number of characters in
s.
string.cvi() returns the little-endian 16-bit value of the first two bytes of the substring. It is equivalent to string.byte(s, i) | (string.byte(s, i+1) << 8).
string.cvin() is the big endian variant of string.cvi(). It is equivalent to (string.byte(s, i) << 8) | string.byte(s, i+1).
string.cvn() returns the little-endian 32-bit value of the first four bytes of the substring. It is equivalent to string.byte(s, i) | (string.byte(s, i+1) << 8) | (string.byte(s, i+2) << 16) | (string.byte(s, i+3) << 24).
string.cvln() is the big endian variant of string.cvl(). It is equivalent to (string.byte(s, i) << 24) | (string.byte(s, i+1) << 16) | (string.byte(s, i+2) << 8) | string.byte(s, i+3).