if (charset == null) throw new DEREncodingException("no decoder"); CharsetDecoder decoder = charset.newDecoder(); CharBuffer result = decoder.decode(ByteBuffer.wrap(value)); char[] buf = new char[result.remaining()]; result.get(buf); return new String(buf);
  private String makeString(int tag, byte[] value)    throws IOException  {    Charset charset = null;    switch (tag & 0x1F)      {        case NUMERIC_STRING:        case PRINTABLE_STRING:        case T61_STRING:        case VIDEOTEX_STRING:        case IA5_STRING:        case GRAPHIC_STRING:        case ISO646_STRING:        case GENERAL_STRING:          charset = Charset.forName("ISO-8859-1");          break;        case UNIVERSAL_STRING:          // XXX The docs say UniversalString is encoded in four bytes          // per character, but Java has no support (yet) for UTF-32.          //return new String(buf, "UTF-32");        case BMP_STRING:          charset = Charset.forName("UTF-16BE");          break;        case UTF8_STRING:          charset = Charset.forName("UTF-8");          break;        default:          throw new DEREncodingException("unknown string tag");      }    if (charset == null)      throw new DEREncodingException("no decoder");    CharsetDecoder decoder = charset.newDecoder();    CharBuffer result = decoder.decode(ByteBuffer.wrap(value));    char[] buf = new char[result.remaining()];    result.get(buf);    return new String(buf);  }