[ 
https://issues.apache.org/jira/browse/COCOON3-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13167455#comment-13167455
 ] 

JBert commented on COCOON3-83:
------------------------------

The problem would appear to be in the StringGenerator inner class, in version 
3.0.0-alpha 3 the problem is on line 322:

{code}
    XMLUtils.toSax(new ByteArrayInputStream(this.xmlString.getBytes()), 
XMLGenerator.this.getSAXConsumer());
{code}

This encodes the String to bytes using the JRE platform encoding. A SAX parser 
will later have trouble parsing this bytestream when the XML declares an 
encoding different from the platform encoding.

If I look at line 149, there's this:
{code}
             XMLUtils.toSax(new String(this.bytes, this.encoding), 
XMLGenerator.this.getSAXConsumer());
{code}

This issue could thus be fixed by simply passing the XML String into the toSax 
function, like so:

{code}
             XMLUtils.toSax(this.xmlString, XMLGenerator.this.getSAXConsumer());
{code}
                
> Encoding bug in XMLGenerator (SAX version) when passing a String to the 
> constructor
> -----------------------------------------------------------------------------------
>
>                 Key: COCOON3-83
>                 URL: https://issues.apache.org/jira/browse/COCOON3-83
>             Project: Cocoon 3
>          Issue Type: Bug
>          Components: cocoon-sax
>    Affects Versions: 3.0.0-alpha-3
>            Reporter: JBert
>
> When creating a new org.apache.cocoon.sax.component.XMLGenerator instance 
> with a String argument, the execute method will fail when the XML uses 
> non-ASCII characters.
> See http://stackoverflow.com/a/8471886/983949 for more info with regards to 
> the code.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to