Hi Oleg, Thanks a lot. I hadn't seen this constructor. Problem solved.
Joan. -----Mensaje original----- De: Oleg Kalnichevski [mailto:[email protected]] Enviado el: jueves, 12 de enero de 2012 21:04 Para: HttpClient User Discussion Asunto: RE: Encoding issue On Thu, 2012-01-12 at 20:57 +0100, Joan Balaguero wrote: > Hi Oleg, > > > StringEntity strEntity = new StringEntity(str); > > > This constructor assumes default charset encoding for HTTP content which is > ISO-8859-1. > > > strEntity.setContentType("text/plain; charset=" + ENCODING); > > > This basically causes the content to be decoded incorrectly as long as > ENCODING is not ISO-8859-1. > > > Then, what is my option? Something like: > > ByteArrayEntity bae = new ByteArrayEntity(str.getBytes(ENCODING)); > objPost.setEntity(bae); > > Why do not you simply use StringEntity#StringEntity(String, String) constructor? > Another question: if the StringEntity constructor assumes ISO encoding for > the String, what's the utility of 'entity.setContentType'? To be able to specify a Content-Type with custom attributes besides 'charset'. Oleg > I expected to find an empty constructor to do something like: > StringEntity strEntity = new StringEntity(); > strEntity.setContentType("text/plain; charset=" + ENCODING); > strEntity.setContent(str); > > > Thanks, > Joan. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] ----- No se encontraron virus en este mensaje. Comprobado por AVG - www.avg.com Versión: 2012.0.1901 / Base de datos de virus: 2109/4738 - Fecha de publicación: 01/12/12 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
