private static LinkedBuffer writeUTF8VarDelimited(final CharSequence str, final int index,
            final int len, final int lowerLimit, int expectedSize,
            final WriteSession session, LinkedBuffer lb)
    {
        int lastSize = session.size, offset = lb.offset, withIntOffset = offset + expectedSize;

        if (withIntOffset > lb.buffer.length)
        {
            // not enough space for the varint.
            // create a new buffer.
            lb = new LinkedBuffer(len + expectedSize > session.nextBufferSize ? len + expectedSize
                    : session.nextBufferSize,
                    lb);
            offset = lb.start;
            lb.offset = withIntOffset = offset + expectedSize;

            // fast path
            final LinkedBuffer rb = writeUTF8(str, index, len, session, lb);

            int size = session.size - lastSize;

            if (size < lowerLimit)
            {
                // move one space to the left since the varint is 1-byte smaller
                System.arraycopy(lb.buffer, withIntOffset, lb.buffer, withIntOffset - 1,
                        lb.offset - withIntOffset);

                expectedSize--;
                lb.offset--;
            }

            // update size
            session.size += expectedSize;

            for (; --expectedSize > 0; size >>>= 7)
                lb.buffer[offset++] = (byte) ((size & 0x7F) | 0x80);

            lb.buffer[offset] = (byte) (size);

            return rb;
        }

        if (withIntOffset + len > lb.buffer.length)
        {
            // not enough space for the string.
            lb.offset = withIntOffset;

            // slow path
            final LinkedBuffer rb = writeUTF8(str, index, len,
                    lb.buffer, withIntOffset, lb.buffer.length, session, lb);

            int size = session.size - lastSize;

            if (size < lowerLimit)
            {
                // move one space to the left since the varint is 1-byte smaller
                System.arraycopy(lb.buffer, withIntOffset, lb.buffer, withIntOffset - 1,
                        lb.offset - withIntOffset);

                expectedSize--;
                lb.offset--;
            }

            // update size
            session.size += expectedSize;

            for (; --expectedSize > 0; size >>>= 7)
                lb.buffer[offset++] = (byte) ((size & 0x7F) | 0x80);

            lb.buffer[offset] = (byte) (size);

            return rb;
        }

        // everything fits
        lb.offset = withIntOffset;

        final LinkedBuffer rb = writeUTF8(str, index, len, session, lb);

        int size = session.size - lastSize;

        if (size < lowerLimit)
        {
            // move one space to the left since the varint is 1-byte smaller
            System.arraycopy(lb.buffer, withIntOffset, lb.buffer, withIntOffset - 1,
                    lb.offset - withIntOffset);

            expectedSize--;
            lb.offset--;
        }

        // update size
        session.size += expectedSize;

        for (; --expectedSize > 0; size >>>= 7)
            lb.buffer[offset++] = (byte) ((size & 0x7F) | 0x80);

        lb.buffer[offset] = (byte) (size);

        return rb;
    }
The length of the utf8 bytes is written first before the string - which is fixed 2-bytes.
protostuff-api/src/main/java/io/protostuff/StringSerializer.java