public static LinkedBuffer writeAscii(final CharSequence str, final WriteSession session,
            LinkedBuffer lb)
    {
        final int len = str.length();
        if (len == 0)
            return lb;

        byte[] buffer = lb.buffer;
        int offset = lb.offset, limit = lb.buffer.length;

        // actual size
        session.size += len;

        if (offset + len > limit)
        {
            // slow path
            for (int i = 0; i < len; i++)
            {
                if (offset == limit)
                {
                    // we are done with this LinkedBuffer
                    lb.offset = offset;
                    // reset
                    offset = 0;
                    limit = session.nextBufferSize;
                    buffer = new byte[limit];
                    // grow
                    lb = new LinkedBuffer(buffer, 0, lb);
                }
                buffer[offset++] = (byte) str.charAt(i);
            }
        }
        else
        {
            // fast path
            for (int i = 0; i < len; i++)
                buffer[offset++] = (byte) str.charAt(i);
        }

        lb.offset = offset;

        return lb;
    }
Writes the ascii bytes from the string into the {@link LinkedBuffer}. It is the responsibility of the caller to
know in advance that the string is 100% ascii. E.g if you convert a double/float to a string, you are sure it
only contains ascii chars.
protostuff-api/src/main/java/io/protostuff/StringSerializer.java