[Java] TurboActivate.GetFeatureValue() for checkbox garbage chars at end

I have a checkbox custom field which I retrieve from Java. It looks like I get garbage data at the end of the string returned by TurboActivate.GetFeatureValue():

String s = TurboActivate.GetFeatureValue("thefield", "0"); System.out.println(s.length()); System.out.println(s.charAt(0)); System.out.println((int) s.charAt(1));

With "thefield" checked this prints out

2 1 0

I would expect a string with length 1 just containing the character '1' but there's an extra 0 at the end it seems.

I'm on Mac OS X by the way. Using the latest TurboActive code (downloaded earlier today). I'm using JNA 4.1.0 from Maven Central but I don't think that should make any difference.

We're going to look into this.

Looks like the TurboActivate.GetPKey() method in the Java bindings suffer from the same problem. A 0 char at the end of the string. You might have a general error in the JNA bindings with NUL terminated strings?

Thanks for reporting this, we've fixed it in TurboActivate 4.0 and TurboFloat 4.0. It's a problem in our TurboActivate.java and TurboFloat.java classes. In the meantime you can fix it by replacing this snippet:

"new String(buf.array(), "UTF-8")"

with this:

"new String(buf.array(), "UTF-8").trim()"

Java doesn't handle null characters in a logical manner. Hence needing to trim them off.