hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joan Balaguero" <joan.balagu...@grupoventus.com>
Subject RE: Encoding issue
Date Thu, 12 Jan 2012 20:41:46 GMT
Hi Oleg,

Thanks a lot. I hadn't seen this constructor. Problem solved.

Joan.

-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
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: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


-----
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: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message