X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltos.java;h=37a4f67bfdb278188b7a78c42dcd6091f2edd098;hp=25d97bcf2b5c6fc35c145c201e12ee5c440caea1;hb=4132ac5896114e5f3d8fb3f219422e8933078cf4;hpb=ef3ce687d73c1274ce5368432f4d449b063ce5c0 diff --git a/altosui/Altos.java b/altosui/Altos.java index 25d97bcf..37a4f67b 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -231,10 +231,21 @@ public class Altos { static final Charset unicode_set = Charset.forName("UTF-8"); static String string(int[] bytes, int s, int l) { - byte[] b = new byte[bytes.length]; + if (s + l > bytes.length) { + if (s > bytes.length) { + s = bytes.length; + l = 0; + } else { + l = bytes.length - s; + } + } + + byte[] b = new byte[l]; + for (int i = 0; i < l; i++) b[i] = (byte) bytes[s+i]; - return new String(b, unicode_set); + String n = new String(b, unicode_set); + return n; } static int hexbyte(String s, int i) {