internal void Write()

in src/Shared/Compat/XmlTextEncoder.cs [103:201]


        internal void Write( char[] array, int offset, int count ) {
            if ( null == array ) {
                throw new ArgumentNullException("array");
            }

            if ( 0 > offset ) {
                throw new ArgumentOutOfRangeException("offset");
            }

            if ( 0 > count ) {
                throw new ArgumentOutOfRangeException("count");
            }

            if ( count > array.Length - offset ) {
                throw new ArgumentOutOfRangeException("count");
            }

            if ( cacheAttrValue ) {
                attrValue.Append( array, offset, count );
            }

            int endPos = offset + count;
            int i = offset;
            char ch = (char)0;
            for (;;) {
                int startPos = i;
                unsafe {
                    while ( i < endPos && ( xmlCharType.charProperties[ch = array[i]] & XmlCharType.fAttrValue ) != 0 ) { // ( xmlCharType.IsAttributeValueChar( ( ch = array[i] ) ) ) ) {
                        i++;
                    }
                }

                if ( startPos < i ) {
                    textWriter.Write( array, startPos, i - startPos );
                }
                if ( i == endPos ) {
                    break;
                }

                switch ( ch ) {
                    case (char)0x9:
                        textWriter.Write( ch );
                        break;
                    case (char)0xA:
                    case (char)0xD:
                        if ( inAttribute ) {
                            WriteCharEntityImpl( ch );
                        }
                        else {
                            textWriter.Write( ch );
                        }
                        break;

                    case '<':
                        WriteEntityRefImpl( "lt" );
                        break;
                    case '>':
                        WriteEntityRefImpl( "gt" );
                        break;
                    case '&':
                        WriteEntityRefImpl( "amp" );
                        break;
                    case '\'':
                        if ( inAttribute && quoteChar == ch ) {
                            WriteEntityRefImpl( "apos" );
                        }
                        else {
                            textWriter.Write( '\'' );
                        }
                        break;
                    case '"':
                        if ( inAttribute && quoteChar == ch ) {
                            WriteEntityRefImpl( "quot" );
                        }
                        else {
                            textWriter.Write( '"' );
                        }
                        break;
                    default:
                        if ( XmlCharType.IsHighSurrogate( ch ) ) {
                            if ( i + 1 < endPos ) {
                                WriteSurrogateChar( array[++i], ch );
                            }
                            else {
                                throw new ArgumentException( "Xml_SurrogatePairSplit" );
                            }
                        }
                        else if ( XmlCharType.IsLowSurrogate( ch ) ) {
                            throw CreateInvalidHighSurrogateCharException( ch );
                        }
                        else {
                            Debug.Assert( ( ch < 0x20 && !xmlCharType.IsWhiteSpace( ch ) ) || ( ch > 0xFFFD ) );
                            WriteCharEntityImpl( ch );
                        }
                        break;
                }
                i++;
            }
        }