Blob:getString

Edit

Returns a binary string containing the Blob's data.

data = Blob:getString(offset, size)

Arguments

NameTypeDefaultDescription
offsetnumber0 A byte offset into the Blob where the string will start.
sizenumbernil The number of bytes the string will contain. If nil, the rest of the data in the Blob will be used, based on the offset parameter.

Returns

NameTypeDescription
datastring The Blob's data.

Notes

This effectively allocates a new copy of the Blob as a Lua string, so this should be avoided for really big Blobs!

Example

Print each byte of the main.lua file:

blob = lovr.filesystem.newBlob('main.lua')
str = blob:getString()

for i = 1, #str do
  print(string.byte(str, i))
end

See also