X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fibex%2Futil%2FPackBytesIntoString.java;fp=src%2Forg%2Fibex%2Futil%2FPackBytesIntoString.java;h=0000000000000000000000000000000000000000;hb=ac84b5a03467c0853c7275105712ece6c71be1f1;hp=1e07e86c0f3bca6de13ed149e2d1935638a01df6;hpb=3f8aa5300e178e8975b0edc896a5a9d303e7bdf3;p=org.ibex.core.git diff --git a/src/org/ibex/util/PackBytesIntoString.java b/src/org/ibex/util/PackBytesIntoString.java deleted file mode 100644 index 1e07e86..0000000 --- a/src/org/ibex/util/PackBytesIntoString.java +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2003 Adam Megacz all rights reserved. -// -// You may modify, copy, and redistribute this code under the terms of -// the GNU Library Public License version 2.1, with the exception of -// the portion of clause 6a after the semicolon (aka the "obnoxious -// relink clause") - -package org.ibex.util; - -/** packs 8-bit bytes into a String of 7-bit chars (to avoid the UTF-8 non-ASCII penalty) */ -public class PackBytesIntoString { - - public static String pack(byte[] b, int off, int len) throws IllegalArgumentException { - if (len % 7 != 0) throw new IllegalArgumentException("len must be a multiple of 7"); - StringBuffer ret = new StringBuffer(); - for(int i=off; i=0; j--) { - l <<= 8; - l |= (b[i + j] & 0xff); - } - for(int j=0; j<8; j++) { - ret.append((char)(l & 0x7f)); - l >>= 7; - } - } - return ret.toString(); - } - - public static byte[] unpack(String s) throws IllegalArgumentException { - if (s.length() % 8 != 0) throw new IllegalArgumentException("string length must be a multiple of 8"); - byte[] ret = new byte[(s.length() / 8) * 7]; - for(int i=0; i=0; j--) { - l <<= 7; - l |= (s.charAt(i + j) & 0x7fL); - } - for(int j=0; j<7; j++) { - ret[(i / 8) * 7 + j] = (byte)(l & 0xff); - l >>= 8; - } - } - return ret; - } -} -