SourceForge has been redesigned. Learn more.
Close

#4 Encoding problem of XMLSerializer#writeDocument

closed
nobody
None
5
2007-10-24
2007-10-24
No

XMLSerializer#write does not return string encoded with the specified charset or UTF-8.

Attached path.

Masato Nagai (of Ariel Networks Inc)

Discussion

  • masato nagai

    masato nagai - 2007-10-24

    net.sf.json.xml.XMLSerializer

     
  • masato nagai

    masato nagai - 2007-10-24
    • summary: An encoding problem of XMLSerializer#write --> Encoding problem of XMLSerializer#writeDocument
     
  • masato nagai

    masato nagai - 2007-10-24

    Logged In: YES
    user_id=1882373
    Originator: YES

    Changed to:
    private String writeDocument( Document doc, String encoding ) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try{
    XomSerializer serializer = (encoding == null) ? new XomSerializer( baos )
    : new XomSerializer( baos, encoding );
    serializer.write( doc );
    encoding = serializer.getEncoding();
    }catch( IOException ioe ){
    throw new JSONException( ioe );
    }

    String str = null;
    try {
    str = baos.toString(encoding);
    } catch (UnsupportedEncodingException uee) {
    throw new JSONException( uee );
    }
    return str;
    }

     
  • aalmiray

    aalmiray - 2007-10-24

    Logged In: YES
    user_id=1192026
    Originator: NO

    Thanks Masato, I'll review the patch and let you know when its ready.

     
  • aalmiray

    aalmiray - 2007-10-24

    Logged In: YES
    user_id=1192026
    Originator: NO

    PATCHED.

     
  • aalmiray

    aalmiray - 2007-10-24
    • status: open --> closed
     

Log in to post a comment.