Menu

#87 Encoding error in org.sbml.jsbml.xml.stax.SBMLWriter

jsbml 1.1
closed-fixed
None
5
2017-03-09
2015-09-01
No

The method "writeSBMLToString(SBMLDocument, String, String)" does not do the encoding right, when the standard charset on the computer is not UTF-8 (e.g. on Windows).

return stream.toString();

should be replaced by

return stream.toString("UTF-8");

Discussion

  • Christian Thöns

    Example:

    SBMLDocument doc = new SBMLDocument(3, 1);
    Model model = doc.createModel("test_model");
    History hist = model.getHistory();
    Creator creator = new Creator("C°", "C°", "C°", "My@EMail.com");
    hist.addCreator(creator);

    // Wrong
    System.out.println(new SBMLWriter().writeSBMLToString(doc, null, null));

    System.out.println();

    // Right
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    new SBMLWriter().write(doc, stream, null, null);
    System.out.println(stream.toString("UTF-8"));

     
  • Nicolas Rodriguez

    Thanks, I will have a look and do some testings on the read and write methods when the default encoding is not UTF-8.

     
  • Nicolas Rodriguez

    • status: unread --> open-accepted
    • assigned_to: Nicolas Rodriguez
    • Group: jsbml 1.0 --> jsbml 1.1
     
  • Nicolas Rodriguez

    • status: open-accepted --> closed-fixed
     
  • Nicolas Rodriguez

    This was fixed some time ago, thanks for the report.

     

Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.
Try Free →