A utility method to convert the char from the byte array to a char.

@param bytes
The byte array containing the char.
@param offset
The index at which the char is located.
@return The char value.
185889
public static char bytesToChar(byte[] bytes, int offset) {
        char result = 0x0;
        for (int i = offset; i < offset + 2; ++i) {
            result = (char) ((result) << 8);
            result |= (bytes[i] & 0x00FF);
        }
        return result;
    }
1321786
public static char[] binToHex(byte[] bytes, int offset, int len) {
        final char[] sb = new char[len * 2];
        final int end = offset + len;
        int index = 0;
        final char[] hexs = hex;
        for (int i = offset; i < end; i++) {
            byte b = bytes[i];
            sb[index++] = (hexs[((b >> 4) & 0xF)]);
            sb[index++] = hexs[((b) & 0xF)];
        }
        return sb;
    }
485671
public static String toHex(byte[] bytes, int offset, int length) {
      return toHex(bytes, offset, length, null);
   }
236820
protected String getString(byte[] data, int offset) {
        if (offset < 0) {
            return "";
        }

        int i = offset;
        while (data[i++] != 0x00) {
            ;
        }
        return getString(data, offset, i - offset - 1);
    }
1290458
public static int getValue(byte[] bytes, int offset) {
    int value = (bytes[offset + 1] << BYTE_1_SHIFT) & BYTE_1_MASK;
    value += (bytes[offset] & BYTE_MASK);
    return value;
  }
644762
public static void intToBytes(int value, byte[] bytes, int offset) {
        bytes[offset + 3] = (byte) (value >>> 0);
        bytes[offset + 2] = (byte) (value >>> 8);
        bytes[offset + 1] = (byte) (value >>> 16);
        bytes[offset + 0] = (byte) (value >>> 24);
    }
960946
public byte[] getByteArray(Integer offset)
   {
      byte[] result = null;

      if (offset != null)
      {
         result = m_map.get(offset);
      }

      return (result);
   }
724861
public static String encodeHexString(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = hexArray[v >>> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }
791394
byte[] convertToBytes(int char1) {
        if (directTextToByte)
            return PdfEncodings.convertToBytes((char)char1, null);
        if (specialMap != null) {
            if (specialMap.containsKey(char1))
                return new byte[]{(byte)specialMap.get(char1)};
            else
                return new byte[0];
        }
        return PdfEncodings.convertToBytes((char)char1, encoding);
    }
841065
public static String convertByteArrayToStringWithoutEscape(byte[] data, int offset, int length) {
    StringBuilder sb = new StringBuilder(length);
    for (int i = offset; i < length && i < data.length; i++) {
      sb.append((char) data[i]);
    }
    return sb.toString();
  }
664442
public static void longToBytes(long value, byte[] bytes, int offset) {
        for (int i = offset + 7; i >= offset; --i) {
            bytes[i] = (byte) value;
            value = value >> 8;
        }
    }
921946
public int read(char []buffer, int offset, int length)
    throws IOException
  {
    byte[] bytes = new byte[length];

    int count = _file.read(bytes, 0, length);

    for (int i = 0; i < count; i++) {
      buffer[offset + i] = (char) bytes[i];

    }

    return count;
  }
1109665
public static int toChars(int i, char[] buf, int offset) {
        if (i < 0) {
            if (i == Integer.MIN_VALUE) {
                writeMinInteger(buf, offset);
                return offset + 11;
            }
            buf[offset++] = '-';
            i = -i;
        }

        offset += stringSizeOf(i);
        getChars(i, offset, buf);
        return offset;
    }
635534
private static String createString(byte bytes[])
    {
        StringBuilder sb = new StringBuilder();
        if (bytes == null)
        {
            sb.append("null");
        }
        else
        {
            for (byte b : bytes)
            {
                if (Character.isLetterOrDigit(b) || Character.isWhitespace(b))
                {
                    sb.append((char)b);
                }
            }
        }
        return sb.toString();
    }
370213
public static int bytesToInt(byte[] bytes, int offset) {
        return ((bytes[offset + 3] & 0xFF) << 0) + ((bytes[offset + 2] & 0xFF) << 8)
                        + ((bytes[offset + 1] & 0xFF) << 16) + ((bytes[offset + 0] & 0xFF) << 24);
    }
826844
public static String hex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = HEXES_SMALL[v >>> 4];
            hexChars[j * 2 + 1] = HEXES_SMALL[v & 0x0F];
        }
        return new String(hexChars);
    }
1331515
public static String decodeString(String encoded,int offset,int length,String charset)
    {
        if (charset==null)
            charset=StringUtil.__ISO_8859_1;
        byte[] bytes=null;
        int n=0;
        
        for (int i=0;i<length;i++)
        {
            char c = encoded.charAt(offset+i);
            if (c<0||c>0xff)
                throw new IllegalArgumentException("Not encoded");
            
            if (c=='+')
            {
                if (bytes==null)
                {
                    bytes=new byte[length*2];
                    encoded.getBytes(offset, offset+i, bytes, 0);
                    n=i;
                }
                bytes[n++] = (byte) ' ';
            }
            else if (c=='%' && (i+2)<length)
            {
                byte b;
                char cn = encoded.charAt(offset+i+1);
                if (cn>='a' && cn<='z')
                    b=(byte)(10+cn-'a');
                else if (cn>='A' && cn<='Z')
                    b=(byte)(10+cn-'A');
                else
                    b=(byte)(cn-'0');
                cn = encoded.charAt(offset+i+2);
                if (cn>='a' && cn<='z')
                    b=(byte)(b*16+10+cn-'a');
                else if (cn>='A' && cn<='Z')
                    b=(byte)(b*16+10+cn-'A');
                else
                    b=(byte)(b*16+cn-'0');

                if (bytes==null)
                {
                    bytes=new byte[length*2];
                    encoded.getBytes(offset, offset+i, bytes, 0);
                    n=i;
                }
                i+=2;
                bytes[n++]=b;
            }
            else if (n>0)
                bytes[n++] = (byte) c;
        }

        if (bytes==null)
        {
            if (offset==0 && encoded.length()==length)
                return encoded;
            return encoded.substring(offset,offset+length);
        }
        
        try
        {
            return new String(bytes,0,n,charset);
        }
        catch (UnsupportedEncodingException e)
        {
            return new String(bytes,0,n);
        }
        
    }