RE: Surrogate pair output support (unit test)

"Dave Byrne" <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <F7F3B826D184FA458E7E2A7DAD18AB980340B868@mdb-mail.MDBCapital.local>
When I submitted the patch, Jason Hunter followed up and asked for test
cases before applying it to CVS which I never did.  Perhaps you could
whip up some junit tests?

-----Original Message-----
From: Olivier Jaquemet [mailto:[email protected]] 
Sent: Thursday, May 07, 2009 6:36 AM
To: [email protected]
Cc: Dave Byrne
Subject: Surrogate pair output support (unit test)

Hi all,

In December 2007, Dave Byrne submitted a patch to add support for 
surrogate pair output :
http://www.jdom.org/pipermail/jdom-interest/2007-December/016016.html

Unfortunately this patch has never made into any JDOM release, nor in 
the cvs (as far as I could find)...

A simple test case for this bug is attached and end of this mail.
As of version 1.1, the test will fail with the following error :
  junit.framework.ComparisonFailure:
    expected: <root>&#x10000; &#65536;</root>
    but was: <root>&#xd800;&#xdc00; &#xd800;&#xdc00;</root>
With the patch submitted by Dave, everything works fine.

Could you add his patch for the next release of JDOM ?
Thank your for you answer !

Regards,
Olivier Jaquemet

-----
The unit test :

  public void testHighSurrogatePair() throws JDOMException, IOException
{
    SAXBuilder builder = new SAXBuilder();
    builder.setExpandEntities(true);
    Document doc = builder.build(new StringReader("<?xml 
version=\"1.0\"?><root>&#x10000; &#65536;</root>"));
   
    Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
    XMLOutputter outputter = new XMLOutputter(format);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    outputter.output(doc, baos);
    String xml = baos.toString();
   
    assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + 
format.getLineSeparator() +
                 "<root>&#x10000; &#x10000;</root>" + 
format.getLineSeparator(), xml);
  }


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.