protected unsafe void WriteElementTextBlock( char *pSrc, char *pSrcEnd ) {
fixed ( byte * pDstBegin = bufBytes ) {
byte * pDst = pDstBegin + this.bufPos;
int ch = 0;
for (;;) {
byte * pDstEnd = pDst + ( pSrcEnd - pSrc );
if ( pDstEnd > pDstBegin + bufLen ) {
pDstEnd = pDstBegin + bufLen;
}
while ( pDst < pDstEnd && ( ( ( xmlCharType.charProperties[( ch = *pSrc )] & XmlCharType.fAttrValue ) != 0 ) && ch <= 0x7F ) ) {
*pDst = (byte)ch;
pDst++;
pSrc++;
}
Debug.Assert( pSrc <= pSrcEnd );
// end of value
if ( pSrc >= pSrcEnd ) {
break;
}
// end of buffer
if ( pDst >= pDstEnd ) {
bufPos = (int)(pDst - pDstBegin);
FlushBuffer();
pDst = pDstBegin + 1;
continue;
}
// some character needs to be escaped
switch ( ch ) {
case '&':
pDst = AmpEntity( pDst );
break;
case '<':
pDst = LtEntity( pDst );
break;
case '>':
pDst = GtEntity( pDst );
break;
case '"':
case '\'':
case (char)0x9:
*pDst = (byte)ch;
pDst++;
break;
case (char)0xA:
if ( newLineHandling == NewLineHandling.Replace ) {
pDst = WriteNewLine( pDst );
}
else {
*pDst = (byte)ch;
pDst++;
}
break;
case (char)0xD:
switch ( newLineHandling ) {
case NewLineHandling.Replace:
// Replace "\r\n", or "\r" with NewLineChars
if ( pSrc[1] == '\n' ) {
pSrc++;
}
pDst = WriteNewLine( pDst );
break;
case NewLineHandling.Entitize:
// Entitize 0xD
pDst = CarriageReturnEntity( pDst );
break;
case NewLineHandling.None:
*pDst = (byte)ch;
pDst++;
break;
}
break;
default:
if ( InRange( ch, SurHighStart, SurLowEnd ) ) { pDst = EncodeSurrogate( pSrc, pSrcEnd, pDst ); pSrc += 2; } else if ( ch <= 0x7F || ch >= 0xFFFE ) { pDst = InvalidXmlChar( ch, pDst, true ); pSrc++; } else { pDst = EncodeMultibyteUTF8( ch, pDst ); pSrc++; };
continue;
}
pSrc++;
}
bufPos = (int)(pDst - pDstBegin);
textPos = bufPos;
contentPos = 0;
}
}