text: public final ByteBuffer encode(CharBuffer buffer) {try {return newEncoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE).encode(buffer);} catch (CharacterCodingException ex) {throw new Error(ex.getMessage(), ex);}}