/** * Encode a valid Unicode codepoint as a sequence of UTF-8 bytes into a new allocated array. * * @param codepoint Unicode codepoint to encode * @return number of bytes written * @throws IndexOutOfBoundsException if there is insufficient room for the encoded data in the given array */ public static byte[] encode(int codepoint) { byte[] destination = new byte[codePointAsUtf8Length(codepoint)]; encode(codepoint, destination, 0); return destination; }