whizzosoftware / WZWave

A native Java library for interfacing with Z-Wave PC controllers
Eclipse Public License 1.0
33 stars 22 forks source link

libraryVersion contains trailing null-character #3

Closed trycoon closed 8 years ago

trycoon commented 8 years ago

Can't say that this really is a bug, but it's somewhat annoying. The libraryVersion-property of the Version-class contains a trailing ACSII NULL-character (\0), in logfiles it shows up like a additional white space ("[Z-Wave 3.99 ]"), and when I try to copy a large block of a stackdump in Linux my editors truncate the texts when they hit the \0-character.

Here are an example file: zwave.txt

Open up the file in the Chrome browser shows the characters as questionmarks: screen dump

I guess it's a side effect of the conversion from a null-terminated bytearray to a String in the Version-class constructor. Java strings are normally not null-terminated (see page 342 in specs).

I have not tried it, but I guess adding a simple replace() in the constructor could fix it, like this: libraryVersion = new String(buffer.readBytes(12).array()).replace('\0', '');