You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Gergana Georgieva (JIRA)" <ji...@apache.org> on 2011/06/21 09:11:47 UTC

[jira] [Updated] (AXIS2-4309) JSONMessageFormatter isnt using the correct charset encoding

     [ https://issues.apache.org/jira/browse/AXIS2-4309?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gergana Georgieva updated AXIS2-4309:
-------------------------------------

    Attachment: xml-9-jp.xml

This is a test file with Japanese text and Japanese encoding.

> JSONMessageFormatter isnt using the correct charset encoding
> ------------------------------------------------------------
>
>                 Key: AXIS2-4309
>                 URL: https://issues.apache.org/jira/browse/AXIS2-4309
>             Project: Axis2
>          Issue Type: Bug
>    Affects Versions: 1.4.1
>            Reporter: Johannes Wagener
>            Assignee: Andreas Veithen
>             Fix For: 1.6.0
>
>         Attachments: xml-9-jp.xml
>
>
> When using JSONMessageFormatter, i had some trouble with german umlauts. The response wasnt in the correct encoding (UTF-8)
> After debugging for while, i found out that getJSONWriter in JSONMessageFormatter.java and JSONBadgerfishMessageFormatter.java
> is ignoring the requested charset encoding:
>     protected XMLStreamWriter getJSONWriter(OutputStream outStream) {
>         return new BadgerFishXMLStreamWriter(new OutputStreamWriter(outStream));
>     }
> In my case outputStreamWriter was writing in CP819 (or something like that), while the response had a   
> Content-Type: application/json;charset=UTF-8
> so i changed it to:
>     protected XMLStreamWriter getJSONWriter(OutputStream outStream,Charset charset) {
>         return new BadgerFishXMLStreamWriter(new OutputStreamWriter(outStream, charset));
>     }
> when calling getJSONWriter i used:
>  Charset charset = Charset.forName(format.getCharSetEncoding());                    
>  XMLStreamWriter jsonWriter = getJSONWriter(out,charset);
> and catching the UnsupportedEncodingException.
> After changing these 2 files, everything worked as expected.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org