public static void toBytes(String src, int srcOffset, int srcLen, ByteBuffer dst, CharsetEncoder encoder) {
        CharBuffer c = CharBuffer.wrap(src, srcOffset, srcOffset + srcLen);
        encoder.encode(c, dst, true);
    }
Encode a string directly into a ByteBuffer instance.

<p>
This method is somewhat more cumbersome than the rest of the helper
methods in this library, as it is intended for use cases in the following
style, if extraneous copying is highly undesirable:

<pre>
String[] a = {"abc", "def", "ghi\u00e8"};
int[] aLens = {3, 3, 5};
CharsetEncoder ce = Utf8.getNewEncoder();
ByteBuffer forWire = ByteBuffer.allocate(someNumber);

for (int i = 0; i &lt; a.length; i++) {
    forWire.putInt(aLens[i]);
    Utf8.toBytes(a[i], 0, a[i].length(), forWire, ce);
}
</pre>

@see Utf8#getNewEncoder()

@param src the string to encode
@param srcOffset index of first character to encode
@param srcLen number of characters to encode
@param dst the destination ByteBuffer
@param encoder the character encoder to use
vespajlib/src/main/java/com/yahoo/text/Utf8.java