Announcement Announcement Module
Collapse
No announcement yet.
Encoding issue w/ upload of Spanish text file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Encoding issue w/ upload of Spanish text file

    I am trying to upload a file of Spanish text and although I have set the default encoding on my multipartResolver to 'UTF-8' when I create a String by converting the MultipartFile to a byte array it isnt recognizing the Spanish characters.

    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.C ommonsMultipartResolver">
    <property name="defaultEncoding" value="UTF-8"/>
    </bean>

    In the command class:

    Code:
    public void setSpanishTextFile(MultipartFile spanishTextFile) throws UnsupportedEncodingException, IOException {
    		this.spanishTextFile = spanishTextFile;
    		String x = new String(spanishTextFile.getBytes(), "UTF-8");
    		System.out.println(x);
    	}
    The Spanish text file:

    Una cuenta del usuario se ha creado para que le tenga acceso
    Después de que usted haya entrado para la primera vez usted debe cambiar su contraseña. Asegúrese por favor de que su contraseña esté mantenida confidencial siempre.
    ¡Gracias por colocarse con myCochlear.com! Si usted tiene cualesquiera investigaciones, entre en contacto con por favor el puesto de informaciones para hablar a un representante/delegado técnico de cliente.


    Am I missing something here?

  • #2
    I'm pretty sure that System.out.println can't print UTF-8.

    Comment


    • #3
      System.out.println("su contraseña. Asegúrese por favor de que su contraseña esté mantenida co");

      seems to display fine...

      Comment


      • #4
        It was the characters in the file - I opened it in Notepad++ and switched the encoding to UTF-8 and the characters weren't recognized. Sorry to waste your time

        Comment

        Working...
        X