You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ron Piterman <rp...@gmx.net> on 2006/03/31 13:34:57 UTC

commons email: charset question

Hi,
I am trying to send a playin/text message with some iso-8859-1 letters 
like äüß aso, I set the charset property of the SimpleEmail object to 
"iso-8859-1", but it does not get to the header, so the email get 
"scrubmled", displaying question marks instead of these characters...

The header includes a content-type:
text/plain; charset=UTF-8

is there something I am doing wrong?

Is there any specific time one should set the charset (i am doing it 
just after instanciating)?

Cheers,
Ron


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: commons email: charset question

Posted by Thomas Trocha <th...@web.de>.
I just had the same problem!

Try to use MultiPartEMail instead of SimpleEMail:

e.g.:

MultiPartEmail email = new MultiPartEmail();
email.setHostName(smtpServer);
email.addTo(to);
email.setSubject(subject);
email.setCharset("UTF-8");
email.setMsg(text);
email.setFrom(from);
String result = email.send();

sideeffekt will be that there is an attachment symbol when receiving 
such an email! but that is much better that scrambled characters....

hope that will help you and the folks that will come.....

greetz, ToM

Ron Piterman schrieb:
> Hi,
> I am trying to send a playin/text message with some iso-8859-1 letters 
> like äüß aso, I set the charset property of the SimpleEmail object to 
> "iso-8859-1", but it does not get to the header, so the email get 
> "scrubmled", displaying question marks instead of these characters...
> 
> The header includes a content-type:
> text/plain; charset=UTF-8
> 
> is there something I am doing wrong?
> 
> Is there any specific time one should set the charset (i am doing it 
> just after instanciating)?
> 
> Cheers,
> Ron


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Lang] escapeXML() -> Not escaping low characters

Posted by David López Muñoz <dl...@tid.es>.
En Tue, 18 Apr 2006 09:55:27 -0700, Henri Yandell <fl...@gmail.com> escribió:

> On 3/31/06, David López Muñoz <dl...@tid.es> wrote:
>> Hello,
>>
>> I'm trying to escape some texts to be xml-valid and I'm using StringEscapeUtils.escapeXml().
>>
>> I found a problem with low characteres such as #18. They don't seem to be escaped, and therefore they are mixed together with other characteres as if there were normal characteres such as 'a', '1' etc.
>>
>> Am I doing sth wrong? I'm using commons-lang 2.1. Is it a known bug already solved in newer versions?
>
> Sorry for lack of reply. Definitely not fixed yet, and thanks for
> reporting it in bugzilla. There's another bug that complains that high
> characters ARE getting escaped - so definitely something that's up for
> debate :)
>
> Would all low-chars want to be escaped? I suspect that people wouldn't
> want newlines suddenly being escaped and turning the xml into a single
> line. Anyone got any idea if the XML spec even talks about low-chars?
>
> Hen


Thanks Hen,

According to my experience, low characteres MUST be escaped, since I'm having
problems with an XML document partly generated with escapeXml().

The document is generated in order to be read by some other client that
is using xerces. This document is filled in with some fields extracted from our DB.
Unfortunately some of the fields happened to contain some unrequired characters
such as &x18, etc. That would not be a problem, but the resulting document
makes xerces crash. I therefore assume that this is not a valid character
and have to be escaped.

-- 
David López Muñoz
(34) 91 337 4703
msn: dlm@tid.es
Multimedia Technology
Telefónica Investigación y Desarrollo

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Lang] escapeXML() -> Not escaping low characters

Posted by Henri Yandell <fl...@gmail.com>.
On 3/31/06, David López Muñoz <dl...@tid.es> wrote:
> Hello,
>
> I'm trying to escape some texts to be xml-valid and I'm using StringEscapeUtils.escapeXml().
>
> I found a problem with low characteres such as #18. They don't seem to be escaped, and therefore they are mixed together with other characteres as if there were normal characteres such as 'a', '1' etc.
>
> Am I doing sth wrong? I'm using commons-lang 2.1. Is it a known bug already solved in newer versions?

Sorry for lack of reply. Definitely not fixed yet, and thanks for
reporting it in bugzilla. There's another bug that complains that high
characters ARE getting escaped - so definitely something that's up for
debate :)

Would all low-chars want to be escaped? I suspect that people wouldn't
want newlines suddenly being escaped and turning the xml into a single
line. Anyone got any idea if the XML spec even talks about low-chars?

Hen

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


[Lang] escapeXML() -> Not escaping low characters

Posted by David López Muñoz <dl...@tid.es>.
Hello,

I'm trying to escape some texts to be xml-valid and I'm using StringEscapeUtils.escapeXml().

I found a problem with low characteres such as #18. They don't seem to be escaped, and therefore they are mixed together with other characteres as if there were normal characteres such as 'a', '1' etc.

Am I doing sth wrong? I'm using commons-lang 2.1. Is it a known bug already solved in newer versions?

Regards
David

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org