_converter.write(_chars,i0,i-i0);
_converter.write(_chars,i0,n-i0);
        public void write (String s,int offset, int length) throws IOException        {               if (_maxChar==0x80)            {                writeUtf8(s,offset,length);                return;            }                        if (_bytes==null)                _bytes=new ByteArrayOutputStream2(_writeChunk*2);                        if (_converter==null)                _converter=_characterEncoding==null?new OutputStreamWriter(_bytes):new OutputStreamWriter(_bytes,_characterEncoding);                        if (length>16) // TODO - tune or perhaps remove            {                if (_chars==null)                    _chars=new char[_writeChunk];                                    int end=offset+length;                                for (int i=offset;i<end; )                {                    int chunk=_writeChunk;                    int next=i+chunk;                    if (next>end)                    {                        next=end;                        chunk=next-i;                    }                    s.getChars(i, next, _chars, 0);                    i+=chunk;                    for (int n=0;n<chunk;)                    {                        char c=_chars[n];                                                if (c<_maxChar)                         {                            _bytes.writeUnchecked(c);                             n++;                        }                        else                        {                            // write a chunket                            int i0=n++;                            n+=_writeChunk/2;                            if (n>chunk)                                n=chunk;                            _converter.write(_chars,i0,i-i0);                            _converter.flush();                        }                    }                                        _out.write(_bytes.getBuf(),0,_bytes.getCount());                    _bytes.reset();                }            }            else            {                synchronized (_bytes)                {                    int end=offset+length;                                        for (int i=offset;i<end; )                    {                        int next=i+_writeChunk;                        if (next>end)                            next=end;                                                while (i<next)                        {                            char c=s.charAt(i);                                                        if (c<_maxChar)                             {                                _bytes.writeUnchecked(c);                                i++;                            }                            else                            {                                   // write a chunket                                int i0=i;                                i+=_writeChunk/2;                                if (i>next)                                    i=next;                                                                _converter.write(s,i0,i-i0);                                _converter.flush();                            }                        }                                                _out.write(_bytes.getBuf(),0,_bytes.getCount());                        _bytes.reset();                    }                }             }        }