2 Replies Latest reply on Mar 18, 2008 10:23 PM by Keith Naas

    Changing the encoding of the data from a s:fileUpload



      I have a little problem with fileUpload:

      I am uploading text files, which are encoded by the microsoft legacy encoding windows-1252, and I need them in the default UTF8 or whatever Java uses.

      My fileUpload is defined as this:

      <h:form enctype="multipart/form-data">
      <s:fileUpload data="#{fileStaff.data}" contentType="#{fileStaff.contentType}"
        fileName="#{fileStaff.fileName}" accept="text/csv" />

      I am using the byte array version to save my data:

      private byte[] csvData = null;

      and then converting it to a char array to have it read by a BufferedReader:

      char[] chars = new char[bytes.length];
      for(int i=0; i<bytes.length; i++)
        { chars[i] = (char) bytes[i]; }
      bR = new BufferedReader(new CharArrayReader(chars));

      Where can the encoding be changed easily or at all?

      Thanks in advance, Peter