public int generate(int uc,int len,CharBuffer dst){
  if (Character.isBmpCodePoint(uc)) {
    char c=(char)uc;
    if (Character.isSurrogate(c)) {
      error=CoderResult.malformedForLength(len);
      return -1;
    }
    if (dst.remaining() < 1) {
      error=CoderResult.OVERFLOW;
      return -1;
    }
    dst.put(c);
    error=null;
    return 1;
  }
 else   if (Character.isValidCodePoint(uc)) {
    if (dst.remaining() < 2) {
      error=CoderResult.OVERFLOW;
      return -1;
    }
    dst.put(Character.highSurrogate(uc));
    dst.put(Character.lowSurrogate(uc));
    error=null;
    return 2;
  }
 else {
    error=CoderResult.unmappableForLength(len);
    return -1;
  }
}

public int generate ( int uc , int len , CharBuffer dst ) { if ( Character . isBmpCodePoint ( uc ) ) { char c = ( char ) uc ; if ( Character . isSurrogate ( c ) ) { error = CoderResult . malformedForLength ( len ) ; return - 1 ; } if ( dst . remaining ( ) < 1 ) { error = CoderResult . OVERFLOW ; return - 1 ; } dst . put ( c ) ; error = null ; return 1 ; } else if ( Character . isValidCodePoint ( uc ) ) { if ( dst . remaining ( ) < 2 ) { error = CoderResult . OVERFLOW ; return - 1 ; } dst . put ( Character . highSurrogate ( uc ) ) ; dst . put ( Character . lowSurrogate ( uc ) ) ; error = null ; return 2 ; } else { error = CoderResult . unmappableForLength ( len ) ; return - 1 ; } }
generates one or two utf - 16 characters to represent the given ucs - 4 character .
