Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail From: Lars Enderin Newsgroups: comp.lang.java.programmer Subject: Re: javax.mail sends mail with broken charset Date: Thu, 29 May 2014 11:56:39 +0200 Organization: albasani.net Lines: 30 Message-ID: <53870457.5060806@telia.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net oNmMNxNE/a/Lrc/TuxaLAw85q+TeGQQtrlXDQMSU15pxe/IZ8mpcNobVd+pPbfi7C3AFi0e+Fjjos7UULSFwRKFhqsEJqWFhpHKKsEtbrtbqfv3H5zwC96o/oBLmAXmy NNTP-Posting-Date: Thu, 29 May 2014 09:56:48 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="DRqLv0zNCCGOw7A/6RW6Rfgf59khHvNcapqp9s81DG5OSXqmTA61xftLMC+f5ptqED5MtvlIMZDqqOxDQCzf66ipwTXc1LpF7fZkfRgfOOmPYTuuPiiSjGNgFzpkZIzW"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: Cancel-Lock: sha1:snHorKCooB5B+oYq71bN80f7Ajs= Xref: csiph.com comp.lang.java.programmer:28600 2014-05-29 09:35, Laura Schmidt skrev: > On 05/29/2014 09:19 AM, Laura Schmidt wrote: > >> the following change to my code solved the problem: > > .... but I don't know why. The new mail reads like this: > > Message-ID: > <22731732.1.1401347792347.JavaMail.tomcat7@h1403230.stratoserver.net> > Subject: Test > MIME-Version: 1.0 > Content-Type: text/plain;charset=utf-8 > Content-Transfer-Encoding: quoted-printable > Date: Thu, 29 May 2014 09:16:32 +0200 (CEST) > > Test: =C3=A4=C3=9F > > The header is the same, but the code for "δί" changed from "=E4=DF " to > "=C3=A4=C3=9F". > That looks right. To see the original characters, you need a mail client or other program that understands quoted-printable. In your first attempt, you seem to have used ISO-8859-1 as the default encoding. What default encoding does the JVM assume? Inside Java, the characters are encoded as 16-bit characters, a form of UTF-16. The encoding only matters when you write to or from a byte stream or file. -- Lars Enderin