Steve Haslam (araqnid) wrote,
Steve Haslam
araqnid

  • Mood:
  • Music:

JavaMail

JavaMail's character set support is janky. Is this just because it predates the whole InputStream/OutputStream vs Reader/Writer rationalisation? If you blithely write:

message.setContent("this is a string, it cost £20 to write", "text/plain");


It may emit QP content like so:

------=_Part_0_15040737.1106653904705
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

this is a string, it cost =A320 to write


which is broken, argh. The "UTF-8" in the charset is just taken from the system property mail.mime.charset, or file.encoding, but the content has been encoded as Latin-1. In order to fix, I had to write:

message.setContent(new String(bodyString.getBytes("UTF-8"), "ISO-8859-1"), "text/plain");


which is just ridiculous. Between this and the pre-Collections API and other nastiness, I'm seriously considering the possibility of writing my own mail-encoding routines, although not really happy about it. Last time I tried to use GNUmail, it had other bugs, which was also frustrating.
Tags: geek
Subscribe

  • Reading Half-Marathon 2009

    Reading Half-Marathon 2009 Total 02:03:39 Position = 7626 out of ~17,000? The day didn't get off to too good a start: 6am on…

  • Getting back into training

    I guess it won't come as a surprise to those who know me that I've resolved to try and get fitter during the coming year. Which I've pretty much…

  • everyone's having a go...

    I see Mesh have a "God Rest Ye Merry Gentlemen" ditty on their Myspace page... Heading up to the parental home soon. Disorganised, as is…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments