示例#1
0
        private unsafe void WriteUriAttributeText(char *pSrc, char *pSrcEnd)
        {
            if (this.endsWithAmpersand)
            {
                if ((((long)((pSrcEnd - pSrc) / 2)) > 0L) && (pSrc[0] != '{'))
                {
                    this.OutputRestAmps();
                }
                this.endsWithAmpersand = false;
            }

            fixed(char *chRef = base.bufChars)
            {
                char *chPtr2;
                char *pDst = chRef + base.bufPos;
                char  ch   = '\0';

Label_0053:
                chPtr2 = pDst + ((char *)(((long)((pSrcEnd - pSrc) / 2)) * 2L));
                if (chPtr2 > (chRef + base.bufLen))
                {
                    chPtr2 = chRef + base.bufLen;
                }
                while (((pDst < chPtr2) && ((this.xmlCharType.charProperties[ch = pSrc[0]] & 0x80) != 0)) && (ch < '\x0080'))
                {
                    pDst++;
                    pDst[0] = ch;
                    pSrc++;
                }
                if (pSrc >= pSrcEnd)
                {
                    goto Label_0227;
                }
                if (pDst >= chPtr2)
                {
                    base.bufPos = (int)((long)((pDst - chRef) / 2));
                    this.FlushBuffer();
                    pDst = chRef + 1;
                    goto Label_0053;
                }
                switch (ch)
                {
                case '\t':
                case '\'':
                case '<':
                case '>':
                    pDst++;
                    pDst[0] = ch;
                    goto Label_021C;

                case '\n':
                    pDst = XmlEncodedRawTextWriter.LineFeedEntity(pDst);
                    goto Label_021C;

                case '\r':
                    pDst = XmlEncodedRawTextWriter.CarriageReturnEntity(pDst);
                    goto Label_021C;

                case '"':
                    pDst = XmlEncodedRawTextWriter.QuoteEntity(pDst);
                    goto Label_021C;

                case '&':
                    if ((pSrc + 1) != pSrcEnd)
                    {
                        break;
                    }
                    this.endsWithAmpersand = true;
                    goto Label_015C;

                default:
                    fixed(byte *numRef = this.uriEscapingBuffer)
                    {
                        byte *numPtr  = numRef;
                        byte *numPtr2 = numPtr;

                        XmlUtf8RawTextWriter.CharToUTF8(ref pSrc, pSrcEnd, ref numPtr2);
                        while (numPtr < numPtr2)
                        {
                            pDst++;
                            pDst[0] = '%';
                            pDst++;
                            pDst[0] = "0123456789ABCDEF"[numPtr[0] >> 4];
                            pDst++;
                            pDst[0] = "0123456789ABCDEF"[numPtr[0] & 15];
                            numPtr++;
                        }
                    }

                    goto Label_0053;
                }
                if (pSrc[1] != '{')
                {
                    pDst = XmlEncodedRawTextWriter.AmpEntity(pDst);
                    goto Label_021C;
                }
Label_015C:
                pDst++;
                pDst[0] = ch;
Label_021C:
                pSrc++;
                goto Label_0053;
Label_0227:
                base.bufPos = (int)((long)((pDst - chRef) / 2));
            }
        }
示例#2
0
        private unsafe void WriteHtmlAttributeText(char *pSrc, char *pSrcEnd)
        {
            if (this.endsWithAmpersand)
            {
                if ((((long)((pSrcEnd - pSrc) / 2)) > 0L) && (pSrc[0] != '{'))
                {
                    this.OutputRestAmps();
                }
                this.endsWithAmpersand = false;
            }

            fixed(char *chRef = base.bufChars)
            {
                char *chPtr2;
                char *pDst = chRef + base.bufPos;
                char  ch   = '\0';

Label_0053:
                chPtr2 = pDst + ((char *)(((long)((pSrcEnd - pSrc) / 2)) * 2L));
                if (chPtr2 > (chRef + base.bufLen))
                {
                    chPtr2 = chRef + base.bufLen;
                }
                while ((pDst < chPtr2) && ((this.xmlCharType.charProperties[ch = pSrc[0]] & 0x80) != 0))
                {
                    pDst++;
                    pDst[0] = ch;
                    pSrc++;
                }
                if (pSrc >= pSrcEnd)
                {
                    goto Label_0195;
                }
                if (pDst >= chPtr2)
                {
                    base.bufPos = (int)((long)((pDst - chRef) / 2));
                    this.FlushBuffer();
                    pDst = chRef + 1;
                    goto Label_0053;
                }
                switch (ch)
                {
                case '\t':
                case '\'':
                case '<':
                case '>':
                    pDst++;
                    pDst[0] = ch;
                    goto Label_018A;

                case '\n':
                    pDst = XmlEncodedRawTextWriter.LineFeedEntity(pDst);
                    goto Label_018A;

                case '\r':
                    pDst = XmlEncodedRawTextWriter.CarriageReturnEntity(pDst);
                    goto Label_018A;

                case '"':
                    pDst = XmlEncodedRawTextWriter.QuoteEntity(pDst);
                    goto Label_018A;

                case '&':
                    if ((pSrc + 1) != pSrcEnd)
                    {
                        break;
                    }
                    this.endsWithAmpersand = true;
                    goto Label_014B;

                default:
                    base.EncodeChar(ref pSrc, pSrcEnd, ref pDst);
                    goto Label_0053;
                }
                if (pSrc[1] != '{')
                {
                    pDst = XmlEncodedRawTextWriter.AmpEntity(pDst);
                    goto Label_018A;
                }
Label_014B:
                pDst++;
                pDst[0] = ch;
Label_018A:
                pSrc++;
                goto Label_0053;
Label_0195:
                base.bufPos = (int)((long)((pDst - chRef) / 2));
            }
        }