public static byte[] toBytes(String string) {
        // This is just wrapper for String::getBytes. Pre-Java 9 this had a more efficient approach for ASCII-only strings.
        return string.getBytes(UTF_8);
    }
Encode a UTF-8 string.

@param string The string to encode.
@return Utf8 encoded array
vespajlib/src/main/java/com/yahoo/text/Utf8.java