/** * Will try an optimistic approach to utf8 encoding. * That is 4.6x faster that the brute encode for ascii, not accounting for reduced memory footprint and GC. * * @param string The string to encode. * @return Utf8 encoded array */ public static byte[] toBytes(String string) { byte [] utf8 = toBytesAscii(string); return utf8 != null ? utf8 : string.getBytes(StandardCharsets.UTF_8); } /**