public int generate(int uc,int len,CharBuffer dst){
  if (uc <= 0xffff) {
    if (Surrogate.is(uc)) {
      error=CoderResult.malformedForLength(len);
      return -1;
    }
    if (dst.remaining() < 1) {
      error=CoderResult.OVERFLOW;
      return -1;
    }
    dst.put((char)uc);
    error=null;
    return 1;
  }
  if (uc < Surrogate.UCS4_MIN) {
    error=CoderResult.malformedForLength(len);
    return -1;
  }
  if (uc <= Surrogate.UCS4_MAX) {
    if (dst.remaining() < 2) {
      error=CoderResult.OVERFLOW;
      return -1;
    }
    dst.put(Surrogate.high(uc));
    dst.put(Surrogate.low(uc));
    error=null;
    return 2;
  }
  error=CoderResult.unmappableForLength(len);
  return -1;
}

public int generate ( int uc , int len , CharBuffer dst ) { if ( uc <= 0xffff ) { if ( Surrogate . is ( uc ) ) { error = CoderResult . malformedForLength ( len ) ; return - 1 ; } if ( dst . remaining ( ) < 1 ) { error = CoderResult . OVERFLOW ; return - 1 ; } dst . put ( ( char ) uc ) ; error = null ; return 1 ; } if ( uc < Surrogate . UCS4_MIN ) { error = CoderResult . malformedForLength ( len ) ; return - 1 ; } if ( uc <= Surrogate . UCS4_MAX ) { if ( dst . remaining ( ) < 2 ) { error = CoderResult . OVERFLOW ; return - 1 ; } dst . put ( Surrogate . high ( uc ) ) ; dst . put ( Surrogate . low ( uc ) ) ; error = null ; return 2 ; } error = CoderResult . unmappableForLength ( len ) ; return - 1 ; }
generates one or two utf - 16 characters to represent the given ucs - 4 character .
