Buffer:append(var, [encoding]) method
Append binary data to the Buffer with the specified content.
Parameters
var
A variable used to append data the Buffer. Only number, string and table values are permitted with the following behavior :
- number : Append the Buffer with the specified size. All the appended bytes are initialized to zero.
- string : Append the Buffer with the specified string. An optional encoding argument can specify how to interpret the string (see below)
- table : Append the Buffer with the specified table. The table must contain only sequential byte values (for example { 20, 33, 75 })
encoding
An optional string used to specify the encoding when appending the Buffer with a string value :
- "utf8" : Append the Buffer with a UTF8 string encoding, or as raw binary data (default)
- "unicode" : Append the Buffer with an UNICODE (UCS-2 LE) encoded string
- "base64" : Append the Buffer with a base64 encoded string
- "hex" : Append the Buffer with a hexadecimal encoded string
Return value
Returns no value.Example
-- init a Buffer with one byte
local buff = sys.Buffer("AB")
buff:append("CD")
-- outputs "ABCD"
print(buff)