Menu

utf-8 encoding

2008-01-22
2013-04-19
  • Nobody/Anonymous

    Hi,

    I don't know if my posting is at the right place, actually i am new to sourceforge and the hole thing, so please correct me.

    back to my topic:
    I just found out, when i use your survey i get utf8 failures like

    java.io.UTFDataFormatException: invalid byte 2 of 2-byte UTF-8 sequence (0x62)

    when i open the result.xml

    this is because you used the java.io.filewiter which hasn't utf8 encoding

    so i edited your saveXMLAnswers

    +
    OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(outputXMLFile),"UTF-8");

    -
    writer = new FileWriter(new File(outputXMLFile));

    maybe you will aply my changes

    here is the reference i used to fix the problem:

    http://www.malcolmhardie.com/weblogs/angus/2004/10/23/java-filewriter-xml-and-utf-8/

    btw your tool saved me a lot of time thank you

    greetings Konrad

    ps: please ignore my bad spelling

     
    • tieTYT

      tieTYT - 2008-01-22

      ah, thanks for the catch.  I changed this in two places:
      XMLResultWriter(File)
      and
      Survey#saveXMLAnswers(String)

      This is checked into the SVN.  My next task is to add a menu bar to JSurveyLib that allows you to save/load surveys at any time.  After that, I'll probably make a release that will include this fix.

      Thanks again,
      Dan

       
    • tieTYT

      tieTYT - 2008-01-22

      oh and BTW, I think you *could* have worked around this bug by using Survey#saveXMLAnswers(Writer).  Am I wrong about that?  I think you could have passed in new OutputStreamWriter(new FileOutputStream(outputXMLFile),"UTF-8") to that method.

       
    • Nobody/Anonymous

      yes of cause, but that woundln't solve the bug with the FileWriter.

       
      • tieTYT

        tieTYT - 2008-01-23

        right :) just wanted to make sure.  Thanks

         
        • tieTYT

          tieTYT - 2008-01-23

          FYI, i modified all FileReaders in similar ways

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.