public static int computeUTF8Size(final CharSequence str, final int index, final int len)
    {
        int size = len;
        for (int i = index; i < len; i++)
        {
            final char c = str.charAt(i);
            if (c < 0x0080)
                continue;

            if (c < 0x0800)
                size++;
            else
                size += 2;
        }
        return size;
    }
Computes the size of the utf8 string beginning at the specified {@code index} with the specified {@code length}.
protostuff-api/src/main/java/io/protostuff/StringSerializer.java