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

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

        // actual size
        session.size += len;

        if (offset + len > limit)
        {
            // need to flush
            int index = 0, start = lb.start, bufSize = limit - start, available = limit - offset, remaining = len
                    - available;

            // write available space
            while (available-- > 0)
                buffer[offset++] = (byte) str.charAt(index++);

            // flush and reset
            offset = session.flush(buffer, start, bufSize);

            while (remaining-- > 0)
            {
                if (offset == limit)
                    offset = session.flush(buffer, start, bufSize);

                buffer[offset++] = (byte) str.charAt(index++);
            }
        }
        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/StreamedStringSerializer.java