note to self
[org.ibex.util.git] / src / org / ibex / util / Encode.java
index c8f20ef..790c526 100644 (file)
@@ -8,6 +8,8 @@ import java.io.*;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
 
+// FEATURE: add ASCII85Encoding (see pdf spec)
+
 /** General <tt>String</tt> and <tt>byte[]</tt> processing functions,
  *  including Base64 and a safe filename transform.
  *
@@ -71,7 +73,7 @@ public final class Encode {
 
     public static long twoFloatsToLong(float a, float b) {
         return ((Float.floatToIntBits(a) & 0xffffffffL) << 32) | (Float.floatToIntBits(b) & 0xffffffffL); }
-    public static float longToFloat1(long l) { return Float.intBitsToFloat((int)(l >> 32)); }
+    public static float longToFloat1(long l) { return Float.intBitsToFloat((int)((l >> 32) & 0xffffffff)); }
     public static float longToFloat2(long l) { return Float.intBitsToFloat((int)(l & 0xffffffff)); }
 
     private static final char[] fn =
@@ -130,6 +132,8 @@ public final class Encode {
 
     public static byte[] toBase64(String data) { return toBase64(data.getBytes()); }
 
+    public static String toBase64String(byte[] data) { return new String(toBase64(data)); }
+
     /** Encode the input data producong a base 64 encoded byte array.
      *  @return A byte array containing the base 64 encoded data. */
     public static byte[] toBase64(byte[] data) {