Hi all,
Part of my code have to send an email written in Spanish or Catalan, depending of language selected. Both languages have accents and other non-ASCII (7bit) printable characters. That's why I use Unicode to try to avoid printing wrong characters. This is the body (in spanish):
To send email, this does not works:Code:String body = "Se ha recibido la respuesta a la solicitud de tasaci\u00F3n.\n" + "Oficina: " + objDatosTasacion.getDatosOficina().getCentro() + "\n" + "C\u00F3digo tasaci\u00F3n: " + codigoCompuesto + "\n" + "Empresa: " + nombreTasadora + "\n" + "Cliente: " + nombreCliente;
Which generates:Code:BodyPart texto = new MimeBodyPart(); texto.setText(new String(body.getBytes(),"UTF-8"));However, next code works, and print unicode characters successfully:Se ha recibido la respuesta a la solicitud de tasaci?.
Oficina: 2400
C?igo tasaci?: 2400-03-00014
Empresa: Tinsa
Cliente: Pepito Gcia.I just wonder to know why first method does not works if I'm using UTF-8, which is a representation of Unicode, and the second one works. I need to understand how to deal with such characters, because they make me crazyCode:BodyPart texto = new MimeBodyPart(); texto.setText(new String(body.getBytes()));
The OS is IBM-AIX and Java file is created using vi. I'm not sure the encoding used to create java file by vi. Compiler is IBM-JDK 1.5.0.
Thanks a lot in advance,
Albert.



Reply With Quote
Bookmarks