From: Keith Packard Date: Wed, 6 Jul 2011 06:35:50 +0000 (-0700) Subject: altosui: Elide nul bytes at end of telemetry string values X-Git-Tag: 0.9.4.3~31 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=72575dcb9cfbb5c1ccdb3510b9962a6f60ca3fa3 altosui: Elide nul bytes at end of telemetry string values All telemetry fields are fixed length, so any embedded strings are padded with nul bytes. Signed-off-by: Keith Packard --- diff --git a/altosui/Altos.java b/altosui/Altos.java index 37a4f67b..36490844 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -240,9 +240,15 @@ public class Altos { } } + int i; + for (i = l - 1; i >= 0; i--) + if (bytes[s+i] != 0) + break; + + l = i + 1; byte[] b = new byte[l]; - for (int i = 0; i < l; i++) + for (i = 0; i < l; i++) b[i] = (byte) bytes[s+i]; String n = new String(b, unicode_set); return n;