Posted 25 February 2013 - 02:52 AM
This is the root cause of this "suggestion": http://www.computercraft.info/forums2/index.php?/topic/10695-stop-rednet-being-crap/
Test #1: check that :byte and .char work as expected:
Test #2: Check that strings are preserved through events:
To summarize, either queueEvent or pullEvent fail to pass strings containing characters above character 127.
This bug is almost certainly present in 1.5 as well, although I haven't tested it.
Test #1: check that :byte and .char work as expected:
for i = 0, 255 do
local c = string.char(i)
local j = c:byte()
if j ~= i then
print(("FAIL: Converting %d from int->char->int gave %d"):format(i, j))
end
end
PassesTest #2: Check that strings are preserved through events:
for i = 0, 255 do
local c = string.char(i)
os.queueEvent('test', c)
local _, c2 = os.pullEvent('test')
assert(#c == 1 and #c2 == 1) -- to prove these are single-byte strings
local j = c2:byte()
if c ~= c2 then
print(("FAIL: Passing %d through an event gives %d"):format(i, j))
end
end
Fails:
FAIL: Passing 128 through an event gives 239
FAIL: Passing 129 through an event gives 239
FAIL: Passing 130 through an event gives 239
...
FAIL: Passing 255 through an event gives 239
To summarize, either queueEvent or pullEvent fail to pass strings containing characters above character 127.
This bug is almost certainly present in 1.5 as well, although I haven't tested it.