presto-main/src/main/java/io/prestosql/operator/scalar/CharacterStringCasts.java/CharacterStringCasts/codePointsToSliceUtf8
class CharacterStringCasts:    private static Slice codePointsToSliceUtf8(List<Integer> codePoints)
    {
        int length = codePoints.stream()
                .mapToInt(SliceUtf8::lengthOfCodePoint)
                .sum();

        Slice result = Slices.wrappedBuffer(new byte[length]);
        int offset = 0;
        for (int codePoint : codePoints) {
            setCodePointAt(codePoint, result, offset);
            offset += lengthOfCodePoint(codePoint);
        }

        return result;
    }