Results 1 to 4 of 4

Thread: Encoding issue w/ upload of Spanish text file

  1. #1
    Join Date
    Apr 2008
    Posts
    7

    Default 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. #2

    Default

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

  3. #3
    Join Date
    Apr 2008
    Posts
    7

    Default

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

    seems to display fine...

  4. #4
    Join Date
    Apr 2008
    Posts
    7

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •