diff options
author | Keith Packard <keithp@keithp.com> | 2011-07-05 23:35:50 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-07-05 23:35:50 -0700 |
commit | 72575dcb9cfbb5c1ccdb3510b9962a6f60ca3fa3 (patch) | |
tree | 0c2d0c996d117b71b75cd123932e923ce87e6f42 | |
parent | 6ac34f9c8efd464194137ac4ce8228bf9d7d83be (diff) |
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 <keithp@keithp.com>
-rw-r--r-- | altosui/Altos.java | 8 |
1 files changed, 7 insertions, 1 deletions
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; |