• Just found another quite serious problem. The two instances of "len" should be replaced by "datalength". Otherwise you can get problems with binary data with 0x20 in it. For instance 0x0E20 ends up being reported as 0x0E because the 20 is regarded as a space and so is not included in the "len" function results.

    Actually it's not just spaces that affect this it's probably any non character value. Using "datalength" fixes this issue. Note there are two places where len is used.