minor change

This change allows for databuffers to treat numbers like strings and a number that would contain more that 1 byte would be wxpanded to fit into the next. The max length is 4 bytes
This commit is contained in:
Ryan Ward 2019-03-22 21:18:59 -04:00
parent bbfa5e7845
commit 1b0fe31002
2 changed files with 6 additions and 1 deletions

View File

@ -1020,7 +1020,7 @@ function bin.newDataBuffer(size,fill) -- fills with \0 or nul or with what you e
if type(v)=="string" then if type(v)=="string" then
data=v data=v
elseif type(v)=="number" then elseif type(v)=="number" then
data=string.char(v) data=bits.numToBytes(v)
else else
-- try to normalize the data of type v -- try to normalize the data of type v
data=bin.normalizeData(v) data=bin.normalizeData(v)

5
test.lua Normal file
View File

@ -0,0 +1,5 @@
local bin = require("bin")
local bits = bin.bits
test = bin.newDataBuffer(16)
print()