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]

Reply via email to