in athena-udfs-textanalytics/src/main/java/com/amazonaws/athena/udf/textanalytics/TextAnalyticsUDFHandler.java [1160:1170]
private static String truncateUtf8(String string, int maxBytes) throws Exception
{
CharsetEncoder enc = StandardCharsets.UTF_8.newEncoder();
ByteBuffer bb = ByteBuffer.allocate(maxBytes); // note the limit
CharBuffer cb = CharBuffer.wrap(string);
CoderResult r = enc.encode(cb, bb, true);
if (r.isOverflow()) {
string = cb.flip().toString();
}
return string;
}