private unsafe void WriteHtmlAttributeText( char * pSrc, char *pSrcEnd ) {
if ( endsWithAmpersand ) {
if ( pSrcEnd - pSrc > 0 && pSrc[0] != '{' ) {
OutputRestAmps();
}
endsWithAmpersand = false;
}
fixed ( char * pDstBegin = bufChars ) {
char * pDst = pDstBegin + this.bufPos;
char ch = (char)0;
for (;;) {
char * pDstEnd = pDst + ( pSrcEnd - pSrc );
if ( pDstEnd > pDstBegin + bufLen ) {
pDstEnd = pDstBegin + bufLen;
}
while ( pDst < pDstEnd && ( ( ( xmlCharType.charProperties[( ch = *pSrc )] & XmlCharType.fAttrValue ) != 0 ) ) ) {
*pDst++ = (char)ch;
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 '&':
if ( pSrc + 1 == pSrcEnd ) {
endsWithAmpersand = true;
}
else if ( pSrc[1] != '{' ) {
pDst = XmlEncodedRawTextWriter.AmpEntity(pDst);
break;
}
*pDst++ = (char)ch;
break;
case '"':
pDst = QuoteEntity( pDst );
break;
case '<':
case '>':
case '\'':
case (char)0x9:
*pDst++ = (char)ch;
break;
case (char)0xD:
// do not normalize new lines in attributes - just escape them
pDst = CarriageReturnEntity( pDst );
break;
case (char)0xA:
// do not normalize new lines in attributes - just escape them
pDst = LineFeedEntity( pDst );
break;
default:
EncodeChar( ref pSrc, pSrcEnd, ref pDst);
continue;
}
pSrc++;
}
bufPos = (int)(pDst - pDstBegin);
}
}