Пример #1
0
        public virtual void DiscardsSpuriousByteOrderMark()
        {
            String     html   = "\uFEFF<html><head><title>One</title></head><body>Two</body></html>";
            ByteBuffer buffer = EncodingUtil.GetEncoding("UTF-8").Encode(html);
            Document   doc    = DataUtil.ParseByteData(buffer, "UTF-8", "http://foo.com/", iText.StyledXmlParser.Jsoup.Parser.Parser
                                                       .HtmlParser());

            NUnit.Framework.Assert.AreEqual("One", doc.Head().Text());
        }
Пример #2
0
 public virtual void WrongMetaCharsetFallback()
 {
     try {
         byte[]     input    = "<html><head><meta charset=iso-8></head><body></body></html>".GetBytes("UTF-8");
         ByteBuffer inBuffer = ByteBuffer.Wrap(input);
         Document   doc      = DataUtil.ParseByteData(inBuffer, null, "http://example.com", iText.StyledXmlParser.Jsoup.Parser.Parser
                                                      .HtmlParser());
         String expected = "<html>\n" + " <head>\n" + "  <meta charset=\"iso-8\">\n" + " </head>\n" + " <body></body>\n"
                           + "</html>";
         NUnit.Framework.Assert.AreEqual(expected, doc.ToString());
     }
     catch (ArgumentException ex) {
         NUnit.Framework.Assert.Fail(ex.Message);
     }
 }