encode
Convenience method that encodes Unicode characters into bytes in this charset.
An invocation of this method upon a charset cs returns the same result as the expression
{@snippet lang=java :
cs.newEncoder()Content copied to clipboard.onMalformedInput(CodingErrorAction.REPLACE)Content copied to clipboard.onUnmappableCharacter(CodingErrorAction.REPLACE)Content copied to clipboard.encode(bb);Content copied to clipboard}
except that it is potentially more efficient because it can cache encoders between successive invocations.
This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement string. In order to detect such sequences, use the method directly.
Return
A byte buffer containing the encoded characters
Parameters
cb
The char buffer to be encoded